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