Skip to content

Commit

Permalink
Revert back to hard coded uid and gid.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-i-berry committed Aug 19, 2024
1 parent ac322ed commit 261c2c7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 40 deletions.
18 changes: 1 addition & 17 deletions .github/workflows/test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,15 @@ jobs:
- name: Build test environment
working-directory: docker/tests
run: |
# create env file
export USER_ID="$(id -u)"
export GROUP_ID="$(id -g)"
echo "${GROUP_ID}:${USER_ID}"
docker compose build
# make sure data directory exists has correct permissions
mkdir ./data
sudo chown -R "$(id -g)":"$(id -u)" ./data
- name: Run containers
working-directory: docker/tests
run: |
export USER_ID="$(id -u)"
export GROUP_ID="$(id -g)"
echo "${GROUP_ID}:${USER_ID}"
docker compose up -d
- name: Run CLI tests
working-directory: docker/tests
run: |
sleep 10s
docker logs subscriber
echo "Testing adding subscription"
docker ps
# test adding a subscription
docker exec subscriber bash -c "source /home/wis2downloader/.venv/bin/activate && wis2downloader add-subscription --topic cache/a/wis2/+/services/#"
# test listing subscriptions
Expand All @@ -59,10 +46,7 @@ jobs:
docker exec subscriber bash -c "source /home/wis2downloader/.venv/bin/activate && wis2downloader remove-subscription --topic cache/a/wis2/+/services/#"
- name: Run API tests
working-directory: docker/tests
run: |
export USER_ID="$(id -u)"
export GROUP_ID="$(id -g)"
echo "${GROUP_ID}:${USER_ID}"
run: |
# get metrics
curl http://localhost:5000/metrics
# test adding a subscription
Expand Down
16 changes: 5 additions & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,18 @@ ENV DOWNLOAD_VALIDATE_TOPICS "false"
ENV DOWNLOAD_WORKERS 8
ENV LOG_PATH "/home/wis2downloader/app/logs"
ENV WIS2DOWNLOADER_CONFIG "/home/wis2downloader/app/config/config.json"
ENV HOST_UID 1002
ENV HOST_GID 1002
ENV HOST_UID 1001
ENV HOST_GID 1001

# Update, upgrade packages and install / clean up
RUN apt-get update && \
apt-get upgrade && \
apt-get install -y gettext-base=0.21-12 curl=7.88.1-10+deb12u6 cron=3.0pl1-162 git=1:2.39.2-1.1 sudo && \
apt-get install -y gettext-base=0.21-12 curl=7.88.1-10+deb12u6 cron=3.0pl1-162 git=1:2.39.2-1.1 && \
rm -rf /var/lib/apt/lists/*

# Now setup python env and default user
# RUN groupadd -g "$GROUP_ID" wis2 && \
# useradd -l -u "$USER_ID" wis2downloader && \
# usermod -aG wis2 wis2downloader

# Now setup python env and default user
RUN groupadd wis2 && \
useradd wis2downloader && \
RUN groupadd -g "$GROUP_ID" wis2 && \
useradd -l -u "$USER_ID" wis2downloader && \
usermod -aG wis2 wis2downloader

USER wis2downloader
Expand Down Expand Up @@ -71,7 +66,6 @@ HEALTHCHECK --interval=1m --timeout=3s \
CMD curl -f http://localhost:5000/subscriptions || exit 1

# Final step as root user, updated in entrypoint
USER root
ENTRYPOINT [ "/home/wis2downloader/app/entrypoint.sh" ]
# Run wis2downloader when the container launches
CMD ["/bin/bash", "-c", "gunicorn --bind 0.0.0.0:5000 --workers 1 wis2downloader.app:app"]
11 changes: 0 additions & 11 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#!/bin/bash
# Update build uid and gid to align with those of instance
usermod -u ${HOST_UID} wis2downloader
usermod -s /bin/bash wis2downloader
groupmod -g ${HOST_GID} wis2

# now demote to wis2downlaoder user
su - wis2downloader
echo "Running entrypoint as $(whoami)"
# print the download_dir
echo "Download directory in container: $DOWNLOAD_DIR"

# ensure DOWNLOAD_DIR exists
Expand All @@ -16,8 +7,6 @@ if [ ! -d "$DOWNLOAD_DIR" ]; then
mkdir -p "$DOWNLOAD_DIR"
fi

ls -althF "$DOWNLOAD_DIR"

envsubst < /home/wis2downloader/app/config/config.template > /home/wis2downloader/app/config/config.json

# if session-info.json does not exists in $DOWNLOAD_DIR, create it
Expand Down
2 changes: 1 addition & 1 deletion docker/tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
- "5000:5000"
depends_on:
- broker
# user: ${USER_ID}:${GROUP_ID}
user: "1001:1001"
volumes:
- ./data:/home/wis2downloader/app/data/downloads:rw

0 comments on commit 261c2c7

Please sign in to comment.