Skip to content

Commit

Permalink
clean up, log to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
Trygve Aspenes committed Oct 28, 2024
1 parent be35212 commit fa8dda5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 59 deletions.
57 changes: 2 additions & 55 deletions containers/fastapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,12 @@ FROM docker.io/mambaorg/micromamba:2.0.2-ubuntu24.04
LABEL maintainer="[email protected]"

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 \
Expand Down Expand Up @@ -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"]
8 changes: 4 additions & 4 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fa8dda5

Please sign in to comment.