Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GitHub Actions permission issues by defaulting Dev images to run as the root user #88

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions ckan-2.10/Dockerfile.py3.10
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,24 @@ RUN pip3 install -U pip && \
ckan config-tool ${CKAN_INI} "beaker.session.secret = " && \
ckan config-tool ${CKAN_INI} "ckan.plugins = ${CKAN__PLUGINS}"

# Create entrypoint directory for children image scripts
RUN mkdir -p /docker-entrypoint.d && chmod 755 /docker-entrypoint.d

# Create ckan and ckan-sys users and the ckan-sys group plus set up the storage path
RUN groupadd -g 502 ckan-sys && \
useradd -rm -d /srv/app -s /bin/bash -g ckan-sys -u 502 ckan-sys && \
useradd -rm -d /srv/app -s /bin/bash -g ckan-sys -u 503 ckan

COPY setup/prerun.py ${APP_DIR}
COPY setup/start_ckan.sh ${APP_DIR}
ADD https://raw.githubusercontent.com/ckan/ckan/${CKAN_REF}/wsgi.py ${APP_DIR}
RUN chmod 644 ${APP_DIR}/wsgi.py

# Create entrypoint directory for children image scripts
RUN mkdir -p /docker-entrypoint.d && chmod 755 /docker-entrypoint.d

# Set the ownership of the app directory, usr/local and the entrypoint directory to the ckan-sys user
RUN chown -R ckan-sys:ckan-sys ${APP_DIR} && \
chown -R ckan-sys:ckan-sys /docker-entrypoint.d && \
chown -R ckan-sys:ckan-sys /usr/local

# Set the ownership of the CKAN config file, src and the storage path to the ckan user
RUN chown ckan:ckan-sys ${APP_DIR}/ckan.ini && \
chown -R ckan:ckan-sys ${APP_DIR}/src && \
Expand Down Expand Up @@ -133,24 +133,42 @@ ENV SRC_EXTENSIONS_DIR=${APP_DIR}/src_extensions

USER root

# Install CKAN dev requirements
RUN cd ${SRC_DIR}/ckan && \
RUN cd ${SRC_DIR}/ckan && \
pip3 install -r https://raw.githubusercontent.com/ckan/ckan/${CKAN_REF}/dev-requirements.txt

COPY --chown=ckan-sys:ckan-sys setup/unsafe.cert setup/unsafe.key setup/start_ckan_development.sh setup/install_src.sh ${APP_DIR}

# Update local directories
RUN mkdir -p ${SRC_EXTENSIONS_DIR} /var/lib/ckan && \
chown -R ckan-sys:ckan-sys ${SRC_EXTENSIONS_DIR} && \
chown -R ckan:ckan-sys /var/lib/ckan/ && \
chmod 775 ${SRC_EXTENSIONS_DIR}
# These are used to run https on development mode
COPY setup/unsafe.cert setup/unsafe.key setup/start_ckan_development.sh setup/install_src.sh ${APP_DIR}

USER ckan
# Create folder for local extensions sources
RUN mkdir -p ${SRC_EXTENSIONS_DIR}

CMD ["/srv/app/start_ckan_development.sh"]


# ──────────────────────────────────────────────────────────────
## When a non-root user is used for Dev the following code will be needed and the above code will be removed

#FROM base AS dev

#ENV SRC_EXTENSIONS_DIR=${APP_DIR}/src_extensions

#USER root

# Install CKAN dev requirements
#RUN cd ${SRC_DIR}/ckan && \
#pip3 install -r https://raw.githubusercontent.com/ckan/ckan/${CKAN_REF}/dev-requirements.txt

#COPY --chown=ckan-sys:ckan-sys setup/unsafe.cert setup/unsafe.key setup/start_ckan_development.sh setup/install_src.sh ${APP_DIR}

# Update local directories
#RUN mkdir -p ${SRC_EXTENSIONS_DIR} /var/lib/ckan && \
# chown -R ckan-sys:ckan-sys ${SRC_EXTENSIONS_DIR} && \
# chown -R ckan:ckan-sys /var/lib/ckan/ && \
# chmod 775 ${SRC_EXTENSIONS_DIR}

#USER ckan

#CMD ["/srv/app/start_ckan_development.sh"]

# ──────────────────────────────────────────────────────────────

FROM ${ENV} AS final
42 changes: 30 additions & 12 deletions ckan-2.11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ RUN pip3 install -U pip && \
ckan config-tool ${CKAN_INI} "SECRET_KEY = " && \
ckan config-tool ${CKAN_INI} "ckan.plugins = ${CKAN__PLUGINS}"

# Create entrypoint directory for children image scripts
RUN mkdir -p /docker-entrypoint.d && chmod 755 /docker-entrypoint.d

# Create ckan and ckan-sys users and the ckan-sys group plus set up the storage path
RUN groupadd -g 502 ckan-sys && \
useradd -rm -d /srv/app -s /bin/bash -g ckan-sys -u 502 ckan-sys && \
Expand All @@ -93,9 +96,6 @@ COPY setup/start_ckan.sh ${APP_DIR}
ADD https://raw.githubusercontent.com/ckan/ckan/${CKAN_REF}/wsgi.py ${APP_DIR}
RUN chmod 644 ${APP_DIR}/wsgi.py

# Create entrypoint directory for children image scripts
RUN mkdir -p /docker-entrypoint.d && chmod 755 /docker-entrypoint.d

# Set the ownership of the app directory, usr/local and the entrypoint directory to the ckan-sys user
RUN chown -R ckan-sys:ckan-sys ${APP_DIR} && \
chown -R ckan-sys:ckan-sys /docker-entrypoint.d && \
Expand Down Expand Up @@ -132,20 +132,38 @@ USER root
RUN cd ${SRC_DIR}/ckan && \
pip3 install -r https://raw.githubusercontent.com/ckan/ckan/${CKAN_REF}/dev-requirements.txt

COPY --chown=ckan-sys:ckan-sys setup/unsafe.cert setup/unsafe.key setup/start_ckan_development.sh setup/install_src.sh ${APP_DIR}
# These are used to run https on development mode
COPY setup/unsafe.cert setup/unsafe.key setup/start_ckan_development.sh setup/install_src.sh ${APP_DIR}

# Update local directories
RUN mkdir -p ${SRC_EXTENSIONS_DIR} /var/lib/ckan && \
chown -R ckan-sys:ckan-sys ${SRC_EXTENSIONS_DIR} && \
chown -R ckan:ckan-sys /var/lib/ckan/ && \
chmod 775 ${SRC_EXTENSIONS_DIR}

USER ckan
# Create folder for local extensions sources
RUN mkdir -p ${SRC_EXTENSIONS_DIR}

CMD ["/srv/app/start_ckan_development.sh"]


# ──────────────────────────────────────────────────────────────
## When a non-root user is used for Dev the following code will be needed and the above code will be removed

#FROM base AS dev

#ENV SRC_EXTENSIONS_DIR=${APP_DIR}/src_extensions

#USER root

#RUN cd ${SRC_DIR}/ckan && \
#pip3 install -r https://raw.githubusercontent.com/ckan/ckan/${CKAN_REF}/dev-requirements.txt

#COPY --chown=ckan-sys:ckan-sys setup/unsafe.cert setup/unsafe.key setup/start_ckan_development.sh setup/install_src.sh ${APP_DIR}

# Update local directories
#RUN mkdir -p ${SRC_EXTENSIONS_DIR} /var/lib/ckan && \
# chown -R ckan-sys:ckan-sys ${SRC_EXTENSIONS_DIR} && \
# chown -R ckan:ckan-sys /var/lib/ckan/ && \
# chmod 775 ${SRC_EXTENSIONS_DIR}

#USER ckan

#CMD ["/srv/app/start_ckan_development.sh"]

# ──────────────────────────────────────────────────────────────

FROM ${ENV} AS final
44 changes: 30 additions & 14 deletions ckan-2.9/Dockerfile.py3.9
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ RUN pip3 install "webassets==0.12.1" && \
ckan config-tool ${CKAN_INI} "beaker.session.secret = " && \
ckan config-tool ${CKAN_INI} "ckan.plugins = ${CKAN__PLUGINS}"

# Create entrypoint directory for children image scripts
RUN mkdir -p /docker-entrypoint.d && chmod 755 /docker-entrypoint.d

# Create ckan and ckan-sys users and the ckan-sys group plus set up the storage path
RUN groupadd -g 502 ckan-sys && \
useradd -rm -d /srv/app -s /bin/bash -g ckan-sys -u 502 ckan-sys && \
Expand All @@ -101,9 +104,6 @@ COPY setup/start_ckan.sh ${APP_DIR}
ADD https://raw.githubusercontent.com/ckan/ckan/${CKAN_REF}/wsgi.py ${APP_DIR}
RUN chmod 644 ${APP_DIR}/wsgi.py

# Create entrypoint directory for children image scripts
RUN mkdir -p /docker-entrypoint.d && chmod 755 /docker-entrypoint.d

# Set the ownership of the app directory, usr/local and the entrypoint directory to the ckan-sys user
RUN chown -R ckan-sys:ckan-sys ${APP_DIR} && \
chown -R ckan-sys:ckan-sys /docker-entrypoint.d && \
Expand Down Expand Up @@ -138,25 +138,41 @@ ENV SRC_EXTENSIONS_DIR=${APP_DIR}/src_extensions

USER root

# Install CKAN dev requirements
#RUN . ${APP_DIR}/bin/activate && \
RUN cd ${SRC_DIR}/ckan && \
pip3 install -r https://raw.githubusercontent.com/ckan/ckan/${CKAN_REF}/dev-requirements.txt

COPY --chown=ckan-sys:ckan-sys setup/unsafe.cert setup/unsafe.key setup/start_ckan_development.sh setup/install_src.sh ${APP_DIR}
# These are used to run https on development mode
COPY setup/unsafe.cert setup/unsafe.key setup/start_ckan_development.sh ${APP_DIR}

# Update local directories
RUN mkdir -p ${SRC_EXTENSIONS_DIR} /var/lib/ckan && \
chown -R ckan-sys:ckan-sys ${SRC_EXTENSIONS_DIR} && \
chown -R ckan:ckan-sys /var/lib/ckan/ && \
chmod 775 ${SRC_EXTENSIONS_DIR}

USER ckan
# Create folder for local extensions sources
RUN mkdir -p ${SRC_EXTENSIONS_DIR}

CMD ["/srv/app/start_ckan_development.sh"]

## When a non-root user is used for Dev the following code will be needed and the above code will be removed

# ──────────────────────────────────────────────────────────────
#FROM base AS dev

#ENV SRC_EXTENSIONS_DIR=${APP_DIR}/src_extensions

#USER root

# Install CKAN dev requirements
#RUN cd ${SRC_DIR}/ckan && \
#pip3 install -r https://raw.githubusercontent.com/ckan/ckan/${CKAN_REF}/dev-requirements.txt

#COPY --chown=ckan-sys:ckan-sys setup/unsafe.cert setup/unsafe.key setup/start_ckan_development.sh setup/install_src.sh ${APP_DIR}

# Update local directories
#RUN mkdir -p ${SRC_EXTENSIONS_DIR} /var/lib/ckan && \
# chown -R ckan-sys:ckan-sys ${SRC_EXTENSIONS_DIR} && \
# chown -R ckan:ckan-sys /var/lib/ckan/ && \
# chmod 775 ${SRC_EXTENSIONS_DIR}

#USER ckan

#CMD ["/srv/app/start_ckan_development.sh"]

# ──────────────────────────────────────────────────────────────

FROM ${ENV} AS final