diff --git a/Dockerfile b/Dockerfile index e59a2880..43da9e60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,30 @@ -ARG CONDA_ENV_DIR=/opt/condaenv -ARG FREVA_WEB_DIR=/opt/freva_web ARG VERSION FROM condaforge/mambaforge LABEL org.opencontainers.image.authors="DRKZ-CLINT" LABEL org.opencontainers.image.source="https://github.com/FREVA-CLINT/freva-web" LABEL org.opencontainers.image.version="$VERSION" -ARG CONDA_ENV_DIR -ARG FREVA_WEB_DIR RUN set -e && \ groupadd -r -g 1000 freva && \ adduser --uid 1000 --gid 1000 --gecos "Freva user" \ - --shell /bin/bash --disabled-password freva --home ${FREVA_WEB_DIR} &&\ - mkdir -p ${CONDA_ENV_DIR} && chown -R freva:freva $CONDA_ENV_DIR -WORKDIR ${FREVA_WEB_DIR} + --shell /bin/bash --disabled-password freva --home /opt/freva_web &&\ + mkdir -p /opt/condaenv && chown -R freva:freva /opt/condaenv +WORKDIR /opt/freva_web COPY . . -ENV PATH=$CONDA_ENV_DIR/bin:$PATH\ +ENV PATH=/opt/condaenv/bin:$PATH\ DJANGO_SUPERUSER_EMAIL=freva@dkrz.de RUN set -e && \ - mamba env create -y -p ${CONDA_ENV_DIR} -f conda-env.yml &&\ + mamba env create -y -p /opt/condaenv -f conda-env.yml &&\ mamba clean -afy &&\ npm install && npm run build-production &&\ rm -rf node_modules &&\ - echo "export PATH=${PATH}" >> ${FREVA_WEB_DIR}/.bashrc &&\ - mkdir -p ${FREVA_WEB_DIR}/static &&\ - chown -R freva:freva ${FREVA_WEB_DIR} -ENTRYPOINT ["/bin/sh", "entrypoint.sh"] -VOLUME ${FREVA_WEB_DIR}/static + echo "export PATH=${PATH}" >> /opt/freva_web/.bashrc &&\ + mkdir -p /opt/freva_web/static &&\ + mv entrypoint.sh /usr/local/bin/ &&\ + chmod +x /usr/local/bin/entrypoint.sh &&\ + chown -R freva:freva /opt/freva_web +ENTRYPOINT /usr/local/bin/entrypoint.sh +VOLUME /opt/freva_web/static EXPOSE 8000 CMD ./init_django.sh diff --git a/entrypoint.sh b/entrypoint.sh index e5833a19..499075b4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,8 @@ -#!/bin/sh +#!/bin/bash -chown -R freva:freva ${FREVA_WEB_DIR}/static -exec runuser -u freva "$@" +chown -R freva:freva /opt/freva_web/static +if [ "$@" ];then + runuser -u freva -- $@ +else + runuser -u freva -- /opt/freva_web/init_django.sh +fi