Skip to content

Commit 07aea44

Browse files
authored
Archiver: Add user to runtime docker image (#154)
Make uid and gid in container that writes/reads from the LTS configurable.
2 parents df4c8b5 + 7ad6a50 commit 07aea44

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

.env.prod

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ IDP_CLIENT_ID=archiver-service-api
1717
# Image used for backend service
1818
OPENEM_BACKEND_IMAGE_NAME=ghcr.io/swissopenem/archiver-service-api
1919
OPENEM_IMAGE_TAG="latest"
20+
# Root folder where Docker volume of LTS share is mounted, i.e. root folder of the LTS share
21+
LTS_ROOT_FOLDER = /tmp/LTS
22+
# User and group id for LTS: these are the ids used to write files to the LTS. Only this user can read the files again
23+
LTS_USER_ID=999
24+
LTS_GROUP_ID=999
2025
# Backend server api root path
2126
API_ROOT_PATH=/archiver/api/v1
2227

28+
2329
#### Minio
2430
MINIO_REGION="eu-west-1"
2531
MINIO_RETRIEVAL_BUCKET="retrieval"
@@ -45,8 +51,7 @@ PREFECT_JOB_TEMPLATE=prefect-jobtemplate-prod.json
4551
PREFECT_ARCHIVAL_WORKPOOL_NAME=archival-docker-workpool
4652
# Workpool name for retrieval jobs
4753
PREFECT_RETRIEVAL_WORKPOOL_NAME=retrieval-docker-workpool
48-
# Root folder where Docker volume of LTS share is mounted, i.e. root folder of the LTS share
49-
LTS_ROOT_FOLDER = /tmp/LTS
54+
5055

5156
SCICAT_ENDPOINT=https://scopem-openem.ethz.ch/scicat/backend
5257

archiver-service.docker-compose.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,15 @@ services:
155155
args:
156156
LTS_ROOT_FOLDER: ${LTS_ROOT_FOLDER}
157157
PREFECT_VERSION: ${PREFECT_VERSION}
158+
UID: 123
159+
GID: 123
158160
container_name: prefect-flows-deployment
159161
networks:
160162
- scopemarchiver_network
161163
environment:
162164
### Prefect specific values
163165
- PREFECT_LOGGING_LEVEL=${PREFECT_LOGGING_LEVEL}
164166
- PREFECT_API_URL=http://prefect-server:4200/api
165-
- EXTRA_PIP_PACKAGES=prefect-docker==0.6.1
166167
### Deployment values for interpolation in prefect.yaml
167168
- PREFECT_VERSION=${PREFECT_VERSION}
168169
- PREFECT_WORKER_LTS_VOLUME_NAME=scopemarchiver_${PREFECT_WORKER_LTS_VOLUME_NAME}

backend/prefect/runtime.Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ RUN --mount=type=cache,target=/root/.cache/uv \
1616

1717
COPY ./ /app/backend/archiver/
1818

19+
# docker executor needs prefect-docker
20+
RUN uv add prefect-docker==0.6.1
21+
1922
FROM prefecthq/prefect:${PREFECT_VERSION} AS test_runner
2023
RUN mkdir -p /app/backend/archiver
2124

@@ -27,6 +30,7 @@ RUN uv add pytest
2730

2831
RUN uv run pytest tests --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html
2932

33+
3034
FROM prefecthq/prefect:${PREFECT_VERSION} AS runtime
3135
COPY --from=builder --chown=app:app /app/backend/archiver /app/backend/archiver
3236

@@ -40,5 +44,13 @@ RUN systemctl --system enable rpcbind.service
4044
ARG LTS_ROOT_FOLDER=/tmp/LTS
4145
RUN mkdir ${LTS_ROOT_FOLDER}
4246

47+
ARG UID=999
48+
ARG GID=999
49+
RUN chown -R ${UID}:${GID} /app
50+
51+
ARG USER=app
52+
RUN useradd -rm -d /home/${USER} -s /bin/bash -u ${UID} ${USER}
53+
USER ${USER}
54+
4355
ENV PATH="/app/backend/archiver/.venv/bin:$PATH"
4456
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)