Skip to content

Commit 5dc84b7

Browse files
committed
build: add version info into container image label
1 parent 09e55e9 commit 5dc84b7

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM python:3.13-alpine
22

3-
ARG BUILD_DEV
3+
ARG BUILD_ENV
4+
ARG IMAGE_VERSION
5+
46
ENV TZ="Asia/Shanghai"
57
ENV UID=1000
68
ENV GID=1000
@@ -9,7 +11,7 @@ ENV WEBDAV_PORT="8000"
911
ENV WEBDAV_CONFIGFILE="/data/webdav.toml"
1012
ENV WEBDAV_LOGGING_LEVEL="INFO"
1113

12-
RUN if [ "$BUILD_DEV" = "rex" ]; then echo "Change depends" \
14+
RUN if [ "$BUILD_ENV" = "rex" ]; then echo "Change depends" \
1315
&& pip config set global.index-url https://proxpi.h.rexzhang.com/index/ \
1416
&& pip config set install.trusted-host proxpi.h.rexzhang.com \
1517
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
@@ -56,6 +58,7 @@ EXPOSE 8000
5658
CMD [ "/app/entrypoint.sh" ]
5759

5860
LABEL org.opencontainers.image.title="ASGI WebDAV Server"
61+
LABEL org.opencontainers.image.version="$IMAGE_VERSION"
5962
LABEL org.opencontainers.image.authors="Rex Zhang"
60-
LABEL org.opencontainers.image.url="https://hub.docker.com/repository/docker/ray1ex/asgi-webdav"
63+
#LABEL org.opencontainers.image.url="https://hub.docker.com/repository/docker/ray1ex/asgi-webdav"
6164
LABEL org.opencontainers.image.source="https://github.com/rexzhang/asgi-webdav"

fabfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from invoke.context import Context
55

66
_DOCKER_PULL = "docker pull --platform=linux/amd64"
7-
_DOCKER_BUILD = "docker buildx build --platform=linux/amd64 --build-arg BUILD_DEV=rex"
7+
_DOCKER_BUILD = "docker buildx build --platform=linux/amd64 --build-arg BUILD_ENV=rex" # TODO: t-string
88
_DOCKER_RUN = "docker run --platform=linux/amd64"
99
_c = Context()
1010

@@ -104,7 +104,11 @@ def env_localhost(c):
104104

105105
def docker_build(c):
106106
print("build docker image...")
107-
c.run(f"{_DOCKER_BUILD} -t {ev.DOCKER_IMAGE_FULL_NAME} .")
107+
from asgi_webdav import __version__
108+
109+
c.run(
110+
f"{_DOCKER_BUILD} --build-arg IMAGE_VERSION={__version__} -t {ev.DOCKER_IMAGE_FULL_NAME} ."
111+
)
108112

109113
say_it("docker image build finished")
110114

0 commit comments

Comments
 (0)