From fa8dda542885d34210f060578ad776ad7295a0e2 Mon Sep 17 00:00:00 2001 From: Trygve Aspenes Date: Mon, 28 Oct 2024 12:28:25 +0100 Subject: [PATCH] clean up, log to stdout --- containers/fastapi/Dockerfile | 57 ++--------------------------------- docker-entrypoint.sh | 8 ++--- 2 files changed, 6 insertions(+), 59 deletions(-) diff --git a/containers/fastapi/Dockerfile b/containers/fastapi/Dockerfile index 3aff24f..df35b0c 100644 --- a/containers/fastapi/Dockerfile +++ b/containers/fastapi/Dockerfile @@ -4,36 +4,12 @@ FROM docker.io/mambaorg/micromamba:2.0.2-ubuntu24.04 LABEL maintainer="trygveas@met.no" ENV MAPGEN_REPO=https://github.com/metno/mapgen-fastapi.git \ - MAPGEN_VERSION=httpserver + MAPGEN_VERSION=main -#COPY ./app /app # Install dependencies: COPY --chown=$MAMBA_USER:$MAMBA_USER containers/fastapi/environment.yaml /tmp/environment.yaml RUN micromamba install -y -n base --file /tmp/environment.yaml -# USER root -# RUN apt-get update && apt-get install -y --no-install-recommends \ -# git lsof less curl \ -# && rm -rf /var/lib/apt/lists/* -#RUN curl --output /usr/share/keyrings/nginx-keyring.gpg https://unit.nginx.org/keys/nginx-keyring.gpg \ -# && echo "deb [signed-by=/usr/share/keyrings/nginx-keyring.gpg] https://packages.nginx.org/unit/ubuntu/ noble unit\ndeb-src [signed-by=/usr/share/keyrings/nginx-keyring.gpg] https://packages.nginx.org/unit/ubuntu/ noble unit" > /etc/apt/sources.list.d/unit.list \ -# && apt-get update \ -# && apt-cache search unit \ -# && apt-get install -y unit-python3.12 - -#COPY --chown=$MAMBA_USER:$MAMBA_USER ./start.sh /start.sh - -#COPY --chown=$MAMBA_USER:$MAMBA_USER ./gunicorn_conf.py /gunicorn_conf.py - -#COPY --chown=$MAMBA_USER:$MAMBA_USER ./start-reload.sh /start-reload.sh -#RUN chmod +x /start.sh \ -# && chmod +x /start-reload.sh - -# USER root -# RUN apt-get update && apt-get install -y --no-install-recommends \ -# git lsof less curl \ -# && rm -rf /var/lib/apt/lists/* - USER root RUN set -ex \ && ln -s /opt/conda/bin/curl /usr/bin/curl \ @@ -97,43 +73,14 @@ RUN set -ex \ && rm -rf /var/lib/apt/lists/* \ && rm -f /requirements.apt - # && groupadd --gid 999 unit \ - # && useradd \ - # --uid 999 \ - # --gid unit \ - # --no-create-home \ - # --home /nonexistent \ - # --comment "unit user" \ - # --shell /bin/false \ - # unit \ - USER $MAMBA_USER RUN /opt/conda/bin/pip install "git+${MAPGEN_REPO}@${MAPGEN_VERSION}" xncml USER root -# RUN cd / -# RUN mkdir -pv /usr/local/var/lib/unit/ && chown $MAMBA_USER:$MAMBA_USER /usr/local/var/lib/unit/ -# RUN ls -al /usr/sbin/unitd-debug && /usr/sbin/unitd-debug --help WORKDIR /app -#EXPOSE 80 ENV LD_LIBRARY_PATH=/usr/local/lib:/opt/conda/lib:/usr/local/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu -# Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations) -# And then will start Gunicorn with Uvicorn -#CMD ["/start.sh"] -#CMD ["/opt/conda/bin/python", "/opt/conda/lib/python3.12/site-packages/mapgen/main.py"] COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -#USER root -#RUN chown "$MAMBA_USER":"$MAMBA_USER" /var/lib/unit RUN mkdir -pv /usr/share/unit/welcome && chown -R $MAMBA_USER:$MAMBA_USER /usr/share/unit COPY --chown=$MAMBA_USER:$MAMBA_USER welcome.* /usr/share/unit/welcome/ -#USER $MAMBA_USER -#RUN chown unit:unit /var/lib/unit -#RUN mkdir -pv /usr/share/unit/welcome && chown -R unit:unit /usr/share/unit -#COPY --chown=unit:unit welcome.* /usr/share/unit/welcome/ -#USER $MAMBA_USER ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] -#EXPOSE 80 -#RUN echo "After" -#USER unit -CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/unit/control.unit.sock", "--statedir", "/var/lib/unit", "--pid", "/var/run/unit/unit.pid", "--log", "/var/log/unit/unit.log"] -#USER $MAMBA_USER +CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/unit/control.unit.sock", "--statedir", "/var/lib/unit", "--pid", "/var/run/unit/unit.pid", "--log", "/proc/1/fd/1"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 5f14d1c..91adccb 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -22,14 +22,14 @@ curl_put() } if [ "$1" = "unitd" ] || [ "$1" = "unitd-debug" ]; then - echo "$0: $(ls -al /var/lib/unit/)" - /usr/bin/find "/var/lib/unit/" -mindepth 1 -print -quit 2>/dev/null - echo "After $?" + mkdir -pv /var/lib/unit + mkdir -pv /var/run/unit + mkdir -pv /var/log/unit if /usr/bin/find "/var/lib/unit/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then echo "$0: /var/lib/unit/ is not empty, skipping initial configuration..." else echo "$0: Launching Unit daemon to perform initial configuration..." - /usr/sbin/$1 --control unix:/var/run/unit/control.unit.sock --log /var/log/unit/unit.log --statedir /var/lib/unit --pid /var/run/unit/unit.pid + /usr/sbin/$1 --control unix:/var/run/unit/control.unit.sock --log /proc/1/fd/1 --statedir /var/lib/unit --pid /var/run/unit/unit.pid for i in $(/usr/bin/seq $WAITLOOPS); do if [ ! -S /var/run/unit/control.unit.sock ]; then