Skip to content

Commit 26e3e7d

Browse files
authored
Merge pull request #371 from nanotaboada/feature/compose
chore(container): rename Docker Compose file to preferred canonical form
2 parents 5170f54 + 5c0af65 commit 26e3e7d

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ CONTRIBUTING.md
1919
coverage.xml
2020
LICENSE
2121
/tests/
22+
__pycache__/
23+
*.pyc
24+
*.pyo
25+
*.pyd

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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ services:
1616

1717
volumes:
1818
storage:
19+
name: python-samples-fastapi-restful_storage

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..."

scripts/healthcheck.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
22
set -e
33

4-
# Simple health check using curl
5-
curl --fail http://localhost:9000/health
4+
# Minimal curl-based health check with timeout and error reporting
5+
curl --fail --silent --show-error --connect-timeout 1 --max-time 2 http://localhost:9000/health

0 commit comments

Comments
 (0)