Skip to content

Commit

Permalink
Use entrypoint to chown static folder to freva user.
Browse files Browse the repository at this point in the history
  • Loading branch information
antarcticrainforest committed Apr 10, 2024
1 parent b5bf40c commit 9ec8f64
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
26 changes: 12 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
10 changes: 7 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9ec8f64

Please sign in to comment.