Skip to content

Commit afdaa40

Browse files
committed
less files in docker image
Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com>
1 parent c1e65ef commit afdaa40

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

.dockerignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,8 @@ charts/
257257
*.tgz
258258
tests/
259259
*.ini
260-
Dockerfile
260+
Dockerfile
261+
.dockerignore
262+
.gitignore
263+
.pre-commit-config.yaml
264+
*.md

.github/workflows/build.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
context: .
5757
platforms: linux/amd64,linux/arm64
5858
push: true
59+
build-args: |
60+
APP_VERSION=${{ needs.versioning.outputs.FullSemVer }}
5961
tags: |
6062
${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ needs.versioning.outputs.MajorMinorPatch }}
6163
${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:latest

Dockerfile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
FROM python:3.13-slim
22

33
# Install Poetry
4-
RUN pip install poetry>=1.8.3
4+
RUN pip install --no-cache-dir "poetry>=1.8.3"
5+
56
ENV POETRY_NO_INTERACTION=1 \
67
POETRY_VIRTUALENVS_IN_PROJECT=1 \
78
POETRY_VIRTUALENVS_CREATE=1 \
@@ -11,11 +12,21 @@ WORKDIR /app
1112

1213
COPY pyproject.toml poetry.lock* README.md ./
1314
RUN poetry config virtualenvs.create false \
14-
&& poetry install --no-interaction --no-ansi --no-root \
15+
&& poetry install --no-interaction --no-ansi --no-root --only main \
1516
&& rm -rf $POETRY_CACHE_DIR
17+
1618
COPY . .
19+
1720
RUN mkdir -p static/openapi
21+
22+
# create non-root user
23+
RUN useradd -m appuser
24+
USER appuser
25+
26+
# Build-time variable for app version
27+
ARG APP_VERSION=dev
28+
ENV APP_VERSION=${APP_VERSION}
29+
1830
EXPOSE 8000
1931

20-
CMD ["poetry", "run", "fastapi", "run", "server.py"]
21-
# CMD ["poetry", "run", "kopf", "run", "controller.py"]
32+
CMD ["poetry", "run", "fastapi", "run", "server.py"]

server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ async def config(request: Request):
197197
"urls": swaggers,
198198
"title": os.environ.get("TITLE", "Swagger Operator"),
199199
"version": os.environ.get("SWAGGER_OPERATOR_VERSION", ""),
200+
"compiling_version": os.environ.get("APP_VERSION", ""),
200201
"session": request.session,
201202
"settings": {
202203
"enable_oidc": ENABLE_OIDC,

templates/config.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</head>
66
<body>
77
<h1>
8-
{{ title }}{% if version %} - v{{ version }}{% endif %}
8+
{{ title }}{% if version %} - v{{ version }}{% endif %} {% if compiling_version %} ({{ compiling_version }}){% endif %}
99
</h1>
1010

1111

0 commit comments

Comments
 (0)