Skip to content

Commit 20068d0

Browse files
authored
Merge pull request #2086 from wger-project/feature/wger-react-dependencies
Add our react components as a regular dependency
2 parents 481ed1e + d9b5c05 commit 20068d0

File tree

85 files changed

+4328
-10353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+4328
-10353
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ venv
2626
/media/
2727
/static/
2828
/db/
29+
/dist/
30+
/node_modules/
31+
/wger.egg-info
32+
/npm-debug.log*
2933
/extras/open-food-facts/dump/
3034
/extras/authors/commits_cache/
3135
/extras/authors/*.md

.yarnrc.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

extras/authors/generate_authors_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def generate_authors_file(
178178

179179
f.write('\n## Translators\n')
180180
if translators:
181-
for language, translator_data in translators.items():
181+
for language, translator_data in sorted(translators.items()):
182182
f.write('\n')
183183
f.write(f'### {language}\n\n')
184184
for author_email, data in translator_data.items():

extras/docker/demo/Dockerfile

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,20 @@ RUN wget -O- https://deb.nodesource.com/setup_22.x | bash - \
3636
sassc \
3737
nodejs \
3838
&& ln -s /usr/bin/sassc /usr/bin/sass \
39-
&& rm -rf /var/lib/apt/lists/* \
40-
&& corepack enable
39+
&& rm -rf /var/lib/apt/lists/*
4140

4241
# Build the necessary python wheels
43-
# Note that the --mount is a workaround for https://github.com/rust-lang/cargo/issues/8719
4442
WORKDIR /home/wger/src
45-
46-
COPY pyproject.toml /home/wger/src
47-
COPY wger/version.py /home/wger/src/wger/
48-
COPY wger/__init__.py /home/wger/src/wger/
49-
COPY README.md /home/wger/src
50-
COPY package.json /home/wger/src
51-
COPY yarn.lock /home/wger/src
52-
COPY wger/core/static /home/wger/src/wger/core/static
53-
RUN --mount=type=tmpfs,target=/root/.cargo pip3 wheel --no-cache-dir --wheel-dir /wheels --group docker . \
54-
&& yarn install \
55-
&& yarn build:css:sass
43+
COPY README.md pyproject.toml package.json package-lock.json package-lock.json /home/wger/src/
44+
COPY wger/version.py wger/__init__.py /home/wger/src/wger/
45+
COPY wger/core/static /root/src/wger/core/static
46+
RUN npm ci --production \
47+
&& npm run build:css:sass \
48+
&& PACKAGE_NAME="@wger-project/react-components" \
49+
&& PACKAGE_VERSION=$(node -p "require('./package.json').devDependencies['$PACKAGE_NAME']") \
50+
&& TARBALL=$(npm pack ${PACKAGE_NAME}@${PACKAGE_VERSION}) \
51+
&& mkdir -p node_modules/${PACKAGE_NAME} \
52+
&& tar -xzf ${TARBALL} -C node_modules/${PACKAGE_NAME} --strip-components=1
5653

5754

5855
########
@@ -94,7 +91,8 @@ RUN chmod 0644 /etc/cron.d/wger \
9491
&& touch /var/log/cron.log
9592

9693
COPY --chown=wger:www-data . /home/wger/src
97-
COPY --from=builder --chown=wger:wger /home/wger/src/wger/core/static/yarn /home/wger/src/wger/core/static/yarn
94+
COPY --chown=wger:wger --from=builder /home/wger/src/node_modules /home/wger/src/node_modules
95+
COPY --chown=wger:wger --from=builder /home/wger/src/wger/core/static/bootstrap-compiled.css /home/wger/src/core/static/bootstrap-compiled.css
9896

9997
# Set up the application
10098
RUN ln -s /home/wger/static/CACHE /var/www

extras/docker/development/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ RUN wget -O- https://deb.nodesource.com/setup_22.x | bash - \
1818
sassc \
1919
&& apt-get clean \
2020
&& rm -rf /var/lib/apt/lists/* \
21-
&& ln -s /usr/bin/yarnpkg /usr/bin/yarn \
2221
&& ln -s /usr/bin/sassc /usr/bin/sass
2322

2423
USER wger
2524
COPY --chown=wger:wger . /home/wger/src
26-
RUN yarn install:force \
27-
&& yarn build:css:sass \
25+
RUN npm install \
26+
&& npm run build:css:sass \
2827
&& pip3 install --break-system-packages --user --group dev --editable .

extras/docker/production/Dockerfile

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ RUN wget -O- https://deb.nodesource.com/setup_22.x | bash - \
3232
unzip \
3333
nodejs \
3434
&& rm -rf /var/lib/apt/lists/* \
35-
&& corepack enable \
3635
&& mkdir -p /root/src/wger/core/static
3736

3837

@@ -42,33 +41,32 @@ RUN wget -O- https://deb.nodesource.com/setup_22.x | bash - \
4241
WORKDIR /root/src
4342

4443
# 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
44+
COPY pyproject.toml README.md /root/src/
45+
COPY wger/version.py wger/__init__.py /root/src/wger/
4946

50-
# NB: the --mount tmpfs is a workaround for https://github.com/rust-lang/cargo/issues/8719
51-
RUN --mount=type=tmpfs,target=/root/.cargo \
52-
pip3 wheel \
47+
# NB: this was a workound for https://github.com/rust-lang/cargo/issues/8719
48+
# which was needed when building rust dependencies for arm/v7. If we re-enable
49+
# the arch, we will probably need to add it again (same for demo, etc).
50+
# --mount=type=tmpfs,target=/root/.cargo
51+
RUN pip3 wheel \
5352
--no-cache-dir \
5453
--wheel-dir /wheels \
5554
--group docker . \
5655
&& ln -s /usr/bin/sassc /usr/bin/sass
5756

58-
# Build the JS and CSS files
59-
COPY package.json yarn.lock .yarnrc.yml ./
57+
# Fetch the JS and CSS files.
58+
# For the react-components npm package, we fetch it manually, extract it and move
59+
# it into node_modules to keep the size of the docker image small(er). Yes, this
60+
# is hacky and there's probably a better way.
61+
COPY package.json package-lock.json download-wger-react-components.sh ./
6062
COPY wger/core/static /root/src/wger/core/static
61-
RUN yarn install \
62-
&& yarn build:css:sass \
63-
&& cd .. \
64-
&& wget https://github.com/wger-project/react/archive/refs/heads/master.zip \
65-
&& unzip master.zip \
66-
&& cd react-master \
67-
&& yarn config set --home enableTelemetry 0 \
68-
&& yarn config set nodeLinker node-modules \
69-
&& yarn install \
70-
&& WGER_STATIC_FOLDER="/root/src/wger/core/static/react" yarn build
71-
63+
RUN npm ci --production \
64+
&& npm run build:css:sass \
65+
&& PACKAGE_NAME="@wger-project/react-components" \
66+
&& PACKAGE_VERSION=$(node -p "require('./package.json').devDependencies['$PACKAGE_NAME']") \
67+
&& TARBALL=$(npm pack ${PACKAGE_NAME}@${PACKAGE_VERSION}) \
68+
&& mkdir -p node_modules/${PACKAGE_NAME} \
69+
&& tar -xzf ${TARBALL} -C node_modules/${PACKAGE_NAME} --strip-components=1
7270

7371
########
7472
# Final
@@ -88,8 +86,8 @@ EXPOSE 8000
8886

8987
# Set up the application
9088
COPY --chown=wger:wger . /home/wger/src
91-
COPY --chown=wger:wger --from=builder /root/src/wger/core/static/yarn /home/wger/src/wger/core/static/yarn
92-
COPY --chown=wger:wger --from=builder /root/src/wger/core/static/react /home/wger/src/wger/core/static/react
89+
COPY --chown=wger:wger --from=builder /root/src/node_modules /home/wger/src/node_modules
90+
COPY --chown=wger:wger --from=builder /root/src/wger/core/static/bootstrap-compiled.css /home/wger/src/core/static/bootstrap-compiled.css
9391
COPY ${DOCKER_DIR}/settings.py /home/wger/src
9492
COPY ${DOCKER_DIR}/settings.py /tmp/
9593
COPY ${DOCKER_DIR}/entrypoint.sh /home/wger/entrypoint.sh

0 commit comments

Comments
 (0)