Skip to content

Commit

Permalink
Merge pull request #44 from mjanez/latest
Browse files Browse the repository at this point in the history
Fix permissions to mount volumes
  • Loading branch information
mjanez authored Sep 22, 2023
2 parents 3511606 + b619427 commit 108137b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
5 changes: 3 additions & 2 deletions ckan-pycsw/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ENV PYCSW_URL=http://localhost:${PYCSW_PORT}/
ENV DEV_MODE=False
ENV TIMEOUT=300
ENV PYCSW_CRON_DAYS_INTERVAL=2
ENV PYCSW_CRON_HOUR_START=4

WORKDIR ${APP_DIR}

Expand All @@ -40,8 +41,8 @@ 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 non-root user
USER $USERNAME
# Switch to root user to change permissions of folders in entrypoint. Then switch back to non-root user.
USER root

Check failure on line 45 in ckan-pycsw/Dockerfile

View workflow job for this annotation

GitHub Actions / manual/build-docker-push:main

DL3002 warning: Last USER should not be root

ENTRYPOINT ["/bin/bash", "./entrypoint.sh"]
CMD ["tail", "-f", "/dev/null"]
9 changes: 4 additions & 5 deletions ckan-pycsw/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Base image
FROM ghcr.io/mjanez/ckan-pycsw:main AS base
FROM ghcr.io/mjanez/ckan-pycsw:latest AS base
LABEL maintainer="[email protected]"

# ckan-pycsw envvars
Expand All @@ -17,19 +17,18 @@ ENV TIMEOUT=300
WORKDIR ${APP_DIR}

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

USER root

# Install dependencies for development mode
RUN apt-get -q -y update && apt-get install -y --no-install-recommends \
procps=2:3.3.17-5 && \
python3 -m pip install --no-cache-dir \
debugpy==1.8.0 && \
rm -rf /var/lib/apt/lists/*

USER $USERNAME
# 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}"]
1 change: 1 addition & 0 deletions ckan-pycsw/Dockerfile.ghcr
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ENV PYCSW_URL=http://localhost:${PYCSW_PORT}/
ENV DEV_MODE=False
ENV TIMEOUT=300
ENV PYCSW_CRON_DAYS_INTERVAL=2
ENV PYCSW_CRON_HOUR_START=4

WORKDIR ${APP_DIR}

Expand Down
2 changes: 1 addition & 1 deletion ckan-pycsw/conf/pycsw.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ database=sqlite:///${PWD}/cite.db
table=records
#filter=type = 'http://purl.org/dc/dcmitype/Dataset'

#[metadata:inspire]
[metadata:inspire]
enabled=true
languages_supported=eng,spa
default_language=eng
Expand Down
9 changes: 8 additions & 1 deletion ckan-pycsw/docker-entrypoint.d/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

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 "$@"
8 changes: 8 additions & 0 deletions ckan-pycsw/docker-entrypoint.d/entrypoint_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

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

exec "$@"

0 comments on commit 108137b

Please sign in to comment.