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

run management container as non-root (#19) #20

Merged
merged 3 commits into from
Aug 20, 2024
Merged
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
14 changes: 10 additions & 4 deletions wis2-gdc-management/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ LABEL maintainer="[email protected]"

ENV TZ="Etc/UTC" \
DEBIAN_FRONTEND="noninteractive" \
DEBIAN_PACKAGES="bash cron curl git python3-pip python3-setuptools vim"
DEBIAN_PACKAGES="bash cron curl git python3-pip python3-setuptools sudo vim"

# copy the app
COPY ./ /app

# add to crontab
COPY ./docker/wis2-gdc-management.cron /etc/cron.d/wis2-gdc-management.cron
COPY ./docker/wis2-gdc-management.cron /var/spool/cron/crontabs/wis2-gdc

RUN apt-get update -y && \
# install dependencies
Expand All @@ -45,7 +45,13 @@ RUN apt-get update -y && \
apt autoremove -y && \
apt-get -q clean && \
rm -rf /var/lib/apt/lists/* && \
chmod 0644 /etc/cron.d/wis2-gdc-management.cron && \
crontab /etc/cron.d/wis2-gdc-management.cron
chmod 0644 /var/spool/cron/crontabs/wis2-gdc && \
crontab /var/spool/cron/crontabs/wis2-gdc && \
# add wis2-gdc user
useradd -ms /bin/bash wis2-gdc && \
adduser wis2-gdc sudo && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

USER wis2-gdc

ENTRYPOINT [ "/app/docker/entrypoint.sh" ]
6 changes: 4 additions & 2 deletions wis2-gdc-management/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@

echo "START /entrypoint.sh"

printenv | grep -v "no_proxy" >> /etc/environment
printenv | grep -v "no_proxy" > /tmp/environment
sudo sh -c 'cat /tmp/environment >> /etc/environment'
rm -f /tmp/environment

echo "Starting cron"
service cron start
sudo service cron start
service cron status

echo "Caching WNM schema"
Expand Down
2 changes: 1 addition & 1 deletion wis2-gdc-management/docker/wis2-gdc-management.cron
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0 0 * * * su -c "wis2-gdc archive $WIS2_GDC_METADATA_ARCHIVE_ZIPFILE" > /proc/1/fd/1 2>/proc/1/fd/2
0 0 * * * wis2-gdc archive $WIS2_GDC_METADATA_ARCHIVE_ZIPFILE > /proc/1/fd/1 2>/proc/1/fd/2
Loading