initial codes try 4
This commit is contained in:
41
Dockerfile
41
Dockerfile
@@ -1,21 +1,22 @@
|
||||
FROM ubuntu:24.04
|
||||
# Simpler base: Debian slim + Python + pip out of the box
|
||||
FROM python:3.12-slim
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV APP_DIR=/opt/containers/nats-registration-listener
|
||||
ENV DATA_DIR=${APP_DIR}/data
|
||||
# venv path and ensure it’s first on PATH for runtime & build steps
|
||||
ENV VENV_PATH=/opt/venv
|
||||
ENV PATH=${VENV_PATH}/bin:${PATH}
|
||||
ENV PATH=/usr/local/bin:$PATH
|
||||
|
||||
# Minimal deps + Python + venv + dos2unix for CRLF→LF
|
||||
# Minimal tools we actually use:
|
||||
# - tini: pid1
|
||||
# - curl: optional for TLS_CA_URL
|
||||
# - dos2unix: fix CRLF if committed from Windows
|
||||
# (jq is optional; if you don't need it, remove it)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
bash curl jq ca-certificates tini python3 python3-venv python3-pip dos2unix \
|
||||
tini curl dos2unix \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create a virtual environment and install python deps inside it
|
||||
RUN python3 -m venv ${VENV_PATH} \
|
||||
&& python -m pip install --no-cache-dir --upgrade pip \
|
||||
&& python -m pip install --no-cache-dir --upgrade nats-py
|
||||
# Python deps (no venv needed on this base image)
|
||||
RUN python -m pip install --no-cache-dir --upgrade pip nats-py
|
||||
|
||||
# App payload (immutable inside image)
|
||||
RUN mkdir -p ${APP_DIR}/app/bin
|
||||
@@ -24,17 +25,21 @@ COPY files/entrypoint.sh /usr/local/bin/nats-registration-entrypoint
|
||||
COPY files/healthcheck.sh /usr/local/bin/nats-registration-healthcheck
|
||||
COPY files/nats_registration_listener.py /usr/local/bin/nats_registration_listener.py
|
||||
|
||||
# Normalize line endings & set exec bits (Windows-safe)
|
||||
RUN dos2unix /usr/local/bin/nats-registration-entrypoint \
|
||||
# Normalize line endings (CRLF/BOM safe) and set exec bits
|
||||
RUN sed -i '1s/^\xEF\xBB\xBF//' /usr/local/bin/nats-registration-entrypoint && \
|
||||
sed -i '1s/^\xEF\xBB\xBF//' /usr/local/bin/nats-registration-healthcheck && \
|
||||
sed -i '1s/^\xEF\xBB\xBF//' /opt/containers/nats-registration-listener/app/bin/nats-registration-listener.sh && \
|
||||
sed -i '1s/^\xEF\xBB\xBF//' /usr/local/bin/nats_registration_listener.py && \
|
||||
dos2unix /usr/local/bin/nats-registration-entrypoint \
|
||||
/usr/local/bin/nats-registration-healthcheck \
|
||||
${APP_DIR}/app/bin/nats-registration-listener.sh \
|
||||
/usr/local/bin/nats_registration_listener.py \
|
||||
&& chmod +x /usr/local/bin/nats-registration-entrypoint \
|
||||
/opt/containers/nats-registration-listener/app/bin/nats-registration-listener.sh \
|
||||
/usr/local/bin/nats_registration_listener.py && \
|
||||
chmod +x /usr/local/bin/nats-registration-entrypoint \
|
||||
/usr/local/bin/nats-registration-healthcheck \
|
||||
${APP_DIR}/app/bin/nats-registration-listener.sh
|
||||
/opt/containers/nats-registration-listener/app/bin/nats-registration-listener.sh
|
||||
|
||||
WORKDIR ${APP_DIR}/app
|
||||
|
||||
# Use tini as PID1; entrypoint validates env and execs the main script
|
||||
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/nats-registration-entrypoint"]
|
||||
# Run via bash explicitly to avoid any shebang weirdness
|
||||
ENTRYPOINT ["/usr/bin/tini", "--", "/bin/bash", "-lc", "/usr/local/bin/nats-registration-entrypoint"]
|
||||
CMD ["/opt/containers/nats-registration-listener/app/bin/nats-registration-listener.sh"]
|
||||
|
||||
Reference in New Issue
Block a user