14
14
FROM wger/base:latest AS builder
15
15
ARG DEBIAN_FRONTEND=noninteractive
16
16
17
- RUN apt update \
17
+ # Need a newer node than what's in ubuntu
18
+ RUN wget -O- https://deb.nodesource.com/setup_22.x | bash - \
19
+ && apt update \
18
20
&& apt install --no-install-recommends -y \
19
21
build-essential \
20
22
python3-dev \
@@ -25,61 +27,67 @@ RUN apt update \
25
27
libwebp-dev \
26
28
libpq-dev \
27
29
rustc \
28
- yarnpkg \
29
30
sassc \
30
- cargo
31
+ cargo \
32
+ unzip \
33
+ nodejs \
34
+ && rm -rf /var/lib/apt/lists/* \
35
+ && corepack enable \
36
+ && mkdir -p /root/src/wger/core/static
37
+
31
38
32
- # Build the necessary python wheels
33
39
#
34
- # PS: the --mount tmpfs is a workaround for https://github.com/rust-lang/cargo/issues/8719
40
+ # Build the python wheels
35
41
#
36
- # PPS: actually only pyproject.toml is needed here, but it seems there is no way
37
- # to tell pip to only build the dependencies and not the project itself as well,
38
- # so we copy enough to make this is possible
39
- COPY pyproject.toml .
40
- COPY wger/version.py ./wger/version.py
41
- COPY wger/__init__.py ./wger/__init__.py
42
- COPY README.md ./README.md
42
+ WORKDIR /root/src
43
+
44
+ # Copy necessary files to build the application
45
+ COPY pyproject.toml /root/src
46
+ COPY wger/version.py /root/src/wger/
47
+ COPY wger/__init__.py /root/src/wger/
48
+ COPY README.md /root/src
49
+ COPY package.json /root/src
50
+ COPY yarn.lock /root/src
51
+ COPY wger/core/static /root/src/wger/core/static
43
52
53
+ # NB: the --mount tmpfs is a workaround for https://github.com/rust-lang/cargo/issues/8719
44
54
RUN --mount=type=tmpfs,target=/root/.cargo \
45
55
pip3 wheel \
46
56
--no-cache-dir \
47
57
--wheel-dir /wheels \
48
58
--group docker . \
49
- && pip3 install \
50
- --break-system-packages \
51
- --no-warn-script-location \
52
- --root-user-action ignore \
53
- --user \
54
- --no-cache-dir /wheels/* \
55
- && ln -s /usr/bin/yarnpkg /usr/bin/yarn \
56
59
&& ln -s /usr/bin/sassc /usr/bin/sass
57
60
58
-
59
- # Download and copy js and css files
60
- COPY . /home/wger/src
61
- WORKDIR /home/wger/src
62
- RUN yarn install \
63
- && yarn build:css:sass
61
+ #
62
+ # Build the JS and CSS files
63
+ #
64
+ RUN yarn config set nodeLinker node-modules \
65
+ && yarn install \
66
+ && yarn build:css:sass \
67
+ && cd .. \
68
+ && wget https://github.com/wger-project/react/archive/refs/heads/master.zip \
69
+ && unzip master.zip \
70
+ && cd react-master \
71
+ && yarn config set --home enableTelemetry 0 \
72
+ && yarn config set nodeLinker node-modules \
73
+ && yarn install \
74
+ && WGER_STATIC_FOLDER="/root/src/wger/core/static/react" yarn build
64
75
65
76
66
77
# #######
67
78
# Final
68
79
# #######
69
80
FROM wger/base:latest AS final
70
- LABEL maintainer= "Roland Geider <[email protected] >"
81
+ LABEL org.opencontainers.image.authors= "wger team <[email protected] >"
71
82
ARG DOCKER_DIR=./extras/docker/production
72
83
ENV PATH="/home/wger/.local/bin:$PATH"
73
-
84
+ WORKDIR /home/wger/src
74
85
EXPOSE 8000
75
86
76
-
77
87
# Set up the application
78
- COPY --from=builder --chown=wger:wger /root/.local /home/wger/.local
79
-
80
- WORKDIR /home/wger/src
81
88
COPY --chown=wger:wger . /home/wger/src
82
- COPY --from=builder --chown=wger:wger /home/wger/src/wger/core/static/yarn /home/wger/src/wger/core/static/yarn
89
+ COPY --chown=wger:wger --from=builder /root/src/wger/core/static/yarn /home/wger/src/wger/core/static/yarn
90
+ COPY --chown=wger:wger --from=builder /root/src/wger/core/static/react /home/wger/src/wger/core/static/react
83
91
COPY ${DOCKER_DIR}/settings.py /home/wger/src
84
92
COPY ${DOCKER_DIR}/settings.py /tmp/
85
93
COPY ${DOCKER_DIR}/entrypoint.sh /home/wger/entrypoint.sh
@@ -93,10 +101,11 @@ RUN chmod +x /home/wger/entrypoint.sh \
93
101
&& chown wger:wger /home/wger/src
94
102
95
103
USER wger
96
- RUN pip3 install --break-system-packages --user --editable . \
97
- && mkdir ~/media \
98
- && mkdir ~/static \
99
- && mkdir ~/beat \
100
- && mkdir ~/db
104
+ RUN --mount=type=bind,from=builder,source=/wheels,target=/wheels \
105
+ pip3 install --break-system-packages --no-cache-dir --user /wheels/* \
106
+ && pip3 install --break-system-packages --user . \
107
+ && mkdir -p ~/media ~/static ~/beat ~/db \
108
+ && cd wger \
109
+ && django-admin compilemessages
101
110
102
111
CMD ["/home/wger/entrypoint.sh" ]
0 commit comments