@@ -7,10 +7,9 @@ ARG DOCKER_GID_ARG=1001
7
7
RUN apk add --no-cache \
8
8
su-exec
9
9
10
- # create user ' scu' and adds it to host's docker group
10
+ # create user ` scu` and `docker` group (with same id as in host)
11
11
RUN adduser -D -u 8004 scu &&\
12
- addgroup -g $DOCKER_GID_ARG docker &&\
13
- addgroup scu docker
12
+ addgroup -g $DOCKER_GID_ARG docker
14
13
15
14
ENV HOME /home/scu
16
15
ENV PIP /home/scu/.venv/bin/pip3
@@ -19,10 +18,12 @@ EXPOSE 8000
19
18
VOLUME /home/scu/input
20
19
VOLUME /home/scu/output
21
20
VOLUME /home/scu/log
22
- # VOLUME /var/run/docker.sock DO NOT EXPOSE .. fails!
21
+
22
+ WORKDIR /home/scu
23
23
24
24
# -------------------------- Build stage -------------------
25
- # Keeps same folder structure as in repo so we can reuse relative paths
25
+ #
26
+ # - Preserves relative folder structure
26
27
#
27
28
# + /home/scu/ $HOME
28
29
# + services/sidecar
@@ -42,21 +43,21 @@ RUN python3 -m venv $HOME/.venv &&\
42
43
wheel \
43
44
setuptools
44
45
45
- WORKDIR /home/scu
46
-
47
- # Build context set at repo's root
48
- COPY --chown=scu:scu services/sidecar/requirements $HOME/requirements
49
- COPY services/sidecar/.docker $HOME/.docker
46
+ # TODO: check if scu:scu copy is necessary!?
47
+ COPY --chown=scu:scu services/sidecar/requirements/base.txt requirements-base.txt
48
+ RUN $PIP install --no-cache-dir -r requirements-base.txt &&\
49
+ rm requirements-base.txt
50
50
51
- RUN $PIP install --no-cache-dir -r requirements/base.txt &&\
52
- rm -rf requirements
51
+ COPY --chown=scu:scu services/sidecar/.docker .docker
52
+ COPY --chown=scu:scu services/sidecar/boot.sh boot.sh
53
53
54
54
# --------------------------Development stage -------------------
55
55
FROM build as development
56
56
57
57
ARG HOST_GID_ARG=1000
58
58
59
59
# in dev-mode we give access to `scu` to host's mapped volumes
60
+ # FIXME: files created by scu cannot be deleted by host! we need to do the same group in host?
60
61
RUN addgroup -g $HOST_GID_ARG hgrp &&\
61
62
addgroup scu hgrp && \
62
63
chown -R scu:scu $HOME/.venv
@@ -65,15 +66,15 @@ VOLUME /home/scu/packages
65
66
VOLUME /home/scu/services/sidecar
66
67
67
68
ENV DEBUG 1
68
- WORKDIR /home/scu
69
+ USER root
69
70
ENTRYPOINT [ "/bin/sh" , ".docker/entrypoint.sh" ]
70
- CMD $HOME /boot.sh
71
+ CMD . /boot.sh
71
72
72
73
73
74
# --------------------------Production multi-stage -------------------
74
75
FROM build as build-production
75
76
76
- # Buil context set at repo's root
77
+ # TODO: check if scu:scu copy is necessary in all cases!? since we are just installing?
77
78
COPY --chown=scu:scu packages $HOME/packages
78
79
COPY --chown=scu:scu services/sidecar $HOME/services/sidecar
79
80
@@ -86,13 +87,13 @@ FROM base as production
86
87
87
88
# TODO: PC->MaG some postgresql missing? install non-dev package!?
88
89
89
- COPY --from=build-production --chown=scu:scu $HOME/services/sidecar/ boot.sh $HOME
90
- COPY --from=build-production --chown=scu:scu $HOME/.venv $HOME/ .venv
91
- COPY --from=build-production --chown=scu:scu $HOME/.docker $HOME/ .docker
90
+ COPY --from=build-production --chown=scu:scu $HOME/boot.sh boot.sh
91
+ COPY --from=build-production --chown=scu:scu $HOME/.venv .venv
92
+ COPY --from=build-production --chown=scu:scu $HOME/.docker .docker
92
93
93
94
RUN . $HOME/.venv/bin/activate; pip list
94
95
95
96
ENV DEBUG 0
96
- WORKDIR /home/scu
97
+ USER root
97
98
ENTRYPOINT [ "/bin/sh" , ".docker/entrypoint.sh" ]
98
99
CMD ./boot.sh
0 commit comments