Pārlūkot izejas kodu

Merge pull request #398 from 9seconds/docker-directory

Allow using directory bind mounts for a docker container
tags/v2.2.4^2
Sergei Arkhipov 1 mēnesi atpakaļ
vecāks
revīzija
4f5368aa2a
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
1 mainītis faili ar 15 papildinājumiem un 1 dzēšanām
  1. 15
    1
      Dockerfile

+ 15
- 1
Dockerfile Parādīt failu

@@ -5,6 +5,19 @@ FROM golang:1.26-alpine AS build
5 5
 
6 6
 ENV CGO_ENABLED=0
7 7
 
8
+# this is done for backward compatibility: before that we mounted a config
9
+# into /config.toml. Some application allow mounting directories only,
10
+# so it makes problems. So, instead we are going to do 2 steps:
11
+#  1. Create /config/config.toml as a symlink to /config.toml
12
+#  2. Force /mtg to use /config/config.toml
13
+#
14
+# it helps in both ways: users with directories could use /config directory
15
+# and overlap a symlink by their bind mount. Old users could continue using
16
+# /config.toml as a real config.
17
+RUN set -x \
18
+  && mkdir -p /config \
19
+  && ln -sv /config.toml /config/config.toml
20
+
8 21
 RUN --mount=type=cache,target=/var/cache/apk \
9 22
     set -x \
10 23
     && apk --update add \
@@ -35,8 +48,9 @@ RUN set -x \
35 48
 FROM scratch
36 49
 
37 50
 ENTRYPOINT ["/mtg"]
38
-CMD ["run", "/config.toml"]
51
+CMD ["run", "/config/config.toml"]
39 52
 
40 53
 COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
41 54
 COPY --from=build /app/mtg /mtg
42 55
 COPY --from=build /app/example.config.toml /config.toml
56
+COPY --from=build /config /config

Notiek ielāde…
Atcelt
Saglabāt