Skip to content

Commit

Permalink
Merge pull request #45 from mjanez/latest
Browse files Browse the repository at this point in the history
Revert non-root in Dockerfile
  • Loading branch information
mjanez authored Sep 22, 2023
2 parents 108137b + 74ca6df commit 6a12205
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 24 deletions.
3 changes: 0 additions & 3 deletions ckan-pycsw/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,5 @@ RUN pdm install --no-self --group prod
COPY ckan-pycsw/conf/pycsw.conf.template ckan-pycsw/docker-entrypoint.d/entrypoint.sh ./
COPY ckan2pycsw ckan2pycsw

# Switch to root user to change permissions of folders in entrypoint. Then switch back to non-root user.
USER root

ENTRYPOINT ["/bin/bash", "./entrypoint.sh"]
CMD ["tail", "-f", "/dev/null"]
3 changes: 0 additions & 3 deletions ckan-pycsw/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@ RUN apt-get -q -y update && apt-get install -y --no-install-recommends \
debugpy==1.8.0 && \
rm -rf /var/lib/apt/lists/*

# Switch to root user to change permissions of folders in entrypoint. Then switch back to non-root user.
USER root

ENTRYPOINT ["/bin/bash", "-c", "python3 -m debugpy --listen 0.0.0.0:${PYCSW_DEV_PORT} --wait-for-client ./docker-entrypoint.d/entrypoint_dev.sh"]
CMD ["pdm", "run", "python3", "-m", "gunicorn", "pycsw.wsgi:application", "-b", "0.0.0.0:${PYCSW_PORT}"]
4 changes: 1 addition & 3 deletions ckan-pycsw/Dockerfile.ghcr
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ ENV PYCSW_CRON_HOUR_START=4
WORKDIR ${APP_DIR}

# Update files if needed
COPY ckan-pycsw/conf/pycsw.conf.template ckan-pycsw/docker-entrypoint.d/entrypoint.sh ./

USER $USERNAME
COPY pycsw/conf/pycsw.conf.template docker-entrypoint.d/entrypoint.sh ./

ENTRYPOINT ["/bin/bash", "./entrypoint.sh"]
9 changes: 1 addition & 8 deletions ckan-pycsw/docker-entrypoint.d/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@

set -xeuo pipefail

# Change ownership of log and metadata directories
chown -R $USERNAME:$USERNAME ${APP_DIR}/log
chown -R $USERNAME:$USERNAME ${APP_DIR}/metadata

# Switch to the non-root user
su - $USERNAME

envsubst < pycsw.conf.template > pycsw.conf

#TODO: -Xfrozen_modules=off from: https://bugs.python.org/issue1666807
/wait-for --timeout "$TIMEOUT" "$CKAN_URL" -- pdm run python3 -Xfrozen_modules=off ckan2pycsw/ckan2pycsw.py

exec "$@"
exec "$@"
7 changes: 0 additions & 7 deletions ckan-pycsw/docker-entrypoint.d/entrypoint_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

set -xeuo pipefail

# Change ownership of log and metadata directories
chown -R $USERNAME:$USERNAME ${APP_DIR}/log
chown -R $USERNAME:$USERNAME ${APP_DIR}/metadata

# Switch to the non-root user
su - $USERNAME

envsubst < pycsw.conf.template > pycsw.conf

/wait-for --timeout "$TIMEOUT" "$CKAN_URL" -- pdm run python3 -m ptvsd --host 0.0.0.0 --port "$PYCSW_DEV_PORT" --wait ckan2pycsw/ckan2pycsw.py
Expand Down

0 comments on commit 6a12205

Please sign in to comment.