Skip to content

Commit c509e04

Browse files
committed
Also compile the react application
This makes sure the frontend and its translations are always up to date.
1 parent 3b9615a commit c509e04

File tree

6 files changed

+229
-138
lines changed

6 files changed

+229
-138
lines changed

.dockerignore

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Docker
6+
Dockerfile*
7+
.dockerignore
8+
9+
# Python
10+
__pycache__/
11+
*.pyo
12+
*.pyd
113
.venv
214
venv
3-
node_modules
415
*.sqlite3
5-
**/__pycache__
616
*.egg-info
717

18+
# IDE / OS specific
19+
.idea/
20+
.vscode/
21+
*.swp
22+
.DS_Store
23+
824
# Other files and folders
925
/coverage.lcov
1026
/media/
1127
/static/
1228
/db/
13-
/extras/docker/open-food-facts/dump/*.tar.gz
14-
/extras/docker/open-food-facts/dump/off/*
29+
/extras/open-food-facts/dump/
1530
/extras/authors/commits_cache/
1631
/extras/authors/*.md
1732
/extras/scripts/*.json

extras/docker/base/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
FROM ubuntu:24.04
1212

13-
LABEL maintainer="Roland Geider <[email protected]>"
13+
LABEL org.opencontainers.image.authors="wger team <[email protected]>"
1414

1515
# Install dependencies
1616
ENV DEBIAN_FRONTEND=noninteractive

extras/docker/demo/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ RUN yarn install \
5656
# Final
5757
########
5858
FROM wger/base:latest AS final
59-
LABEL maintainer="Roland Geider <[email protected]>"
59+
LABEL org.opencontainers.image.authors="wger team <[email protected]>"
6060
ENV TERM=xterm
6161
ARG DOCKER_DIR=./extras/docker/demo
6262
EXPOSE 80

extras/docker/production/Dockerfile

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,61 +25,72 @@ RUN apt update \
2525
libwebp-dev \
2626
libpq-dev \
2727
rustc \
28-
yarnpkg \
2928
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
3141

32-
# Build the necessary python wheels
3342
#
34-
# PS: the --mount tmpfs is a workaround for https://github.com/rust-lang/cargo/issues/8719
43+
# Build the python wheels
3544
#
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
4355

56+
# NB: the --mount tmpfs is a workaround for https://github.com/rust-lang/cargo/issues/8719
4457
RUN --mount=type=tmpfs,target=/root/.cargo \
4558
pip3 wheel \
4659
--no-cache-dir \
4760
--wheel-dir /wheels \
4861
--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 \
5662
&& ln -s /usr/bin/sassc /usr/bin/sass
5763

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
6478

6579

6680
########
6781
# Final
6882
########
6983
FROM wger/base:latest AS final
70-
LABEL maintainer="Roland Geider <[email protected]>"
84+
LABEL org.opencontainers.image.authors="wger team <[email protected]>"
7185
ARG DOCKER_DIR=./extras/docker/production
7286
ENV PATH="/home/wger/.local/bin:$PATH"
73-
87+
WORKDIR /home/wger/src
7488
EXPOSE 8000
7589

76-
7790
# Set up the application
78-
COPY --from=builder --chown=wger:wger /root/.local /home/wger/.local
79-
80-
WORKDIR /home/wger/src
8191
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
8394
COPY ${DOCKER_DIR}/settings.py /home/wger/src
8495
COPY ${DOCKER_DIR}/settings.py /tmp/
8596
COPY ${DOCKER_DIR}/entrypoint.sh /home/wger/entrypoint.sh
@@ -93,11 +104,10 @@ RUN chmod +x /home/wger/entrypoint.sh \
93104
&& chown wger:wger /home/wger/src
94105

95106
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 \
101111
&& cd wger \
102112
&& django-admin compilemessages
103113

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
},
1111
"homepage": "https://github.com/wger-project/wger",
1212
"dependencies": {
13-
"htmx.org": "^2.0.5",
13+
"@popperjs/core": "^2.11.8",
1414
"bootstrap": "5.3.7",
1515
"components-font-awesome": "5.9.0",
1616
"datatables.net-bs5": "^2.3.1",
1717
"devbridge-autocomplete": "^1.4.11",
18+
"htmx.org": "^2.0.5",
1819
"jquery": "^3.7.1",
1920
"masonry-layout": "^4.2.2",
2021
"popper.js": "^1.16.1",
@@ -25,5 +26,6 @@
2526
},
2627
"engines": {
2728
"yarn": ">= 1.0.0"
28-
}
29+
},
30+
"packageManager": "[email protected]"
2931
}

0 commit comments

Comments
 (0)