1414FROM wger/base:latest AS builder
1515ARG DEBIAN_FRONTEND=noninteractive
1616
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 \
1820 && apt install --no-install-recommends -y \
1921 build-essential \
2022 python3-dev \
@@ -25,61 +27,67 @@ RUN apt update \
2527 libwebp-dev \
2628 libpq-dev \
2729 rustc \
28- yarnpkg \
2930 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+
3138
32- # Build the necessary python wheels
3339#
34- # PS: the --mount tmpfs is a workaround for https://github.com/rust-lang/cargo/issues/8719
40+ # Build the python wheels
3541#
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
4352
53+ # NB: the --mount tmpfs is a workaround for https://github.com/rust-lang/cargo/issues/8719
4454RUN --mount=type=tmpfs,target=/root/.cargo \
4555 pip3 wheel \
4656 --no-cache-dir \
4757 --wheel-dir /wheels \
4858 --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 \
5659 && ln -s /usr/bin/sassc /usr/bin/sass
5760
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
6475
6576
6677# #######
6778# Final
6879# #######
6980FROM wger/base:latest AS final
70- LABEL maintainer= "Roland Geider <[email protected] >"81+ LABEL org.opencontainers.image.authors= "wger team <[email protected] >"7182ARG DOCKER_DIR=./extras/docker/production
7283ENV PATH="/home/wger/.local/bin:$PATH"
73-
84+ WORKDIR /home/wger/src
7485EXPOSE 8000
7586
76-
7787# Set up the application
78- COPY --from=builder --chown=wger:wger /root/.local /home/wger/.local
79-
80- WORKDIR /home/wger/src
8188COPY --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
8391COPY ${DOCKER_DIR}/settings.py /home/wger/src
8492COPY ${DOCKER_DIR}/settings.py /tmp/
8593COPY ${DOCKER_DIR}/entrypoint.sh /home/wger/entrypoint.sh
@@ -93,10 +101,11 @@ RUN chmod +x /home/wger/entrypoint.sh \
93101 && chown wger:wger /home/wger/src
94102
95103USER 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
101110
102111CMD ["/home/wger/entrypoint.sh" ]
0 commit comments