Skip to content

Commit cf9574c

Browse files
committed
chore(container): simplify creation of dynamically allocated system user
1 parent d56ad28 commit cf9574c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Dockerfile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ LABEL org.opencontainers.image.source="https://github.com/nanotaboada/python-sam
3535

3636
# Copy metadata docs for container registries (e.g.: GitHub Container Registry)
3737
COPY README.md ./
38-
COPY assets ./assets
38+
COPY assets/ ./assets/
3939

4040
# Copy pre-built wheels from builder
41-
COPY --from=builder /app/wheelhouse /app/wheelhouse
41+
COPY --from=builder /app/wheelhouse/ /app/wheelhouse/
4242

4343
# Install dependencies
4444
COPY requirements.txt .
@@ -47,29 +47,29 @@ RUN pip install --no-cache-dir --no-index --find-links /app/wheelhouse -r requir
4747

4848
# Copy application source code
4949
COPY main.py ./
50-
COPY databases ./databases
51-
COPY models ./models
52-
COPY routes ./routes
53-
COPY schemas ./schemas
54-
COPY services ./services
50+
COPY databases/ ./databases/
51+
COPY models/ ./models/
52+
COPY routes/ ./routes/
53+
COPY schemas/ ./schemas/
54+
COPY services/ ./services/
5555

5656
# https://rules.sonarsource.com/docker/RSPEC-6504/
5757

5858
# Copy entrypoint and healthcheck scripts
5959
COPY --chmod=755 scripts/entrypoint.sh ./entrypoint.sh
6060
COPY --chmod=755 scripts/healthcheck.sh ./healthcheck.sh
61-
# Copy pre-seeded SQLite database as init bundle
62-
COPY --chmod=755 storage ./docker-compose
61+
# The 'hold' is our storage compartment within the image. Here, we copy a
62+
# pre-seeded SQLite database file, which Compose will mount as a persistent
63+
# 'storage' volume when the container starts up.
64+
COPY --chmod=755 storage/ ./hold/
6365

6466
# Add non-root user and make volume mount point writable
65-
RUN groupadd --system fastapi && \
66-
adduser --system --ingroup fastapi --disabled-password --gecos '' fastapi && \
67+
RUN adduser --system --disabled-password --group fastapi && \
6768
mkdir -p /storage && \
6869
chown fastapi:fastapi /storage
6970

7071
ENV PYTHONUNBUFFERED=1
7172

72-
# Drop privileges
7373
USER fastapi
7474

7575
EXPOSE 9000

scripts/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -e
33

4-
IMAGE_STORAGE_PATH="/app/docker-compose/players-sqlite3.db"
4+
IMAGE_STORAGE_PATH="/app/hold/players-sqlite3.db"
55
VOLUME_STORAGE_PATH="/storage/players-sqlite3.db"
66

77
echo "✔ Starting container..."

0 commit comments

Comments
 (0)