-
-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1786 from wger-project/feature/improved-docker-image
Improve docker image
- Loading branch information
Showing
14 changed files
with
91 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ on: | |
|
||
env: | ||
REGISTRY_IMAGE: ${{ vars.REGISTRY_REPO }}/server | ||
REGISTRY_IMAGE_ALT: ${{ vars.REGISTRY_REPO }}/devel | ||
|
||
jobs: | ||
build-prod: | ||
|
@@ -42,7 +41,6 @@ jobs: | |
type=raw,value=2.3-dev | ||
images: | | ||
${{ env.REGISTRY_IMAGE }} | ||
${{ env.REGISTRY_IMAGE_ALT }} | ||
- name: Set up QEMU | ||
uses: docker/[email protected] | ||
|
@@ -72,7 +70,7 @@ jobs: | |
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: extras/docker/development/Dockerfile | ||
file: extras/docker/production/Dockerfile | ||
builder: ${{ steps.buildx.outputs.name }} | ||
platforms: ${{ matrix.platform }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
@@ -126,7 +124,6 @@ jobs: | |
type=raw,value=2.3-dev | ||
images: | | ||
${{ env.REGISTRY_IMAGE }} | ||
${{ env.REGISTRY_IMAGE_ALT }} | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,33 +8,32 @@ | |
# docker build --tag wger/base . | ||
# | ||
|
||
FROM ubuntu:22.04 | ||
FROM ubuntu:24.04 | ||
|
||
LABEL maintainer="Roland Geider <[email protected]>" | ||
|
||
# Install dependencies | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt update \ | ||
&& apt install --no-install-recommends -y \ | ||
adduser \ | ||
locales \ | ||
nodejs \ | ||
npm \ | ||
python3-pip \ | ||
sqlite3 \ | ||
wget \ | ||
tzdata \ | ||
libpq5 \ | ||
&& npm install -g yarn sass\ | ||
&& locale-gen en_US.UTF-8 | ||
|
||
# Environmental variables | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
ENV LANG=en_US.UTF-8 | ||
ENV LANGUAGE=en_US:en | ||
ENV LC_ALL=en_US.UTF-8 | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
|
||
# Add wger user | ||
RUN adduser wger --disabled-password --gecos "" | ||
RUN deluser ubuntu | ||
RUN adduser wger --uid 1000 --disabled-password --gecos "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
########## | ||
# Builder | ||
########## | ||
FROM wger/base:latest as builder | ||
FROM wger/base:latest AS builder | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt update \ | ||
|
@@ -32,20 +32,29 @@ RUN apt update \ | |
libpq-dev \ | ||
rustc \ | ||
cargo \ | ||
&& pip install --upgrade pip | ||
yarnpkg \ | ||
sassc | ||
|
||
# Build the necessary python wheels | ||
# Note that the --mount is a workaround for https://github.com/rust-lang/cargo/issues/8719 | ||
COPY requirements* ./ | ||
RUN --mount=type=tmpfs,target=/root/.cargo pip3 wheel --no-cache-dir --wheel-dir /wheels -r requirements_docker.txt | ||
RUN --mount=type=tmpfs,target=/root/.cargo pip3 wheel --no-cache-dir --wheel-dir /wheels -r requirements_docker.txt \ | ||
&& pip3 install --break-system-packages --user --no-cache-dir /wheels/* | ||
|
||
COPY . /home/wger/src | ||
WORKDIR /home/wger/src | ||
RUN ln -s /usr/bin/yarnpkg /usr/bin/yarn \ | ||
&& ln -s /usr/bin/sassc /usr/bin/sass \ | ||
&& yarn install \ | ||
&& yarn build:css:sass | ||
|
||
|
||
######## | ||
# Final | ||
######## | ||
FROM wger/base:latest | ||
LABEL maintainer="Roland Geider <[email protected]>" | ||
|
||
ENV TERM=xterm | ||
ARG DOCKER_DIR=./extras/docker/demo | ||
EXPOSE 80 | ||
|
||
|
@@ -70,45 +79,46 @@ RUN a2dissite 000-default.conf \ | |
# Configure cron | ||
COPY ${DOCKER_DIR}/crontab /etc/cron.d/wger | ||
COPY ${DOCKER_DIR}/venvwrapper /home/wger/venvwrapper | ||
COPY ${DOCKER_DIR}/entrypoint.sh /home/wger/entrypoint.sh | ||
|
||
RUN chmod 0644 /etc/cron.d/wger \ | ||
&& chmod +x /home/wger/venvwrapper /home/wger/entrypoint.sh \ | ||
&& chmod +x /home/wger/venvwrapper \ | ||
&& touch /var/log/cron.log | ||
|
||
COPY --from=builder /wheels /wheels | ||
COPY --chown=wger:www-data . /home/wger/src | ||
COPY --from=builder --chown=wger:wger /home/wger/src/wger/core/static/yarn /home/wger/src/wger/core/static/yarn | ||
|
||
# Set up the application | ||
RUN ln -s /home/wger/static/CACHE /var/www | ||
USER wger | ||
|
||
WORKDIR /home/wger/src | ||
#RUN git clone https://github.com/wger-project/wger.git | ||
RUN python3 -m venv /home/wger/venv | ||
|
||
# Change permissions of some files and folders so the apache process | ||
# can access them. | ||
RUN mkdir -p ~/static/CACHE ~/media \ | ||
&& ln -s /home/wger/static/CACHE /home/wger/src/CACHE \ | ||
&& chmod g+w /home/wger/static/CACHE | ||
|
||
RUN . /home/wger/venv/bin/activate \ | ||
&& pip install --upgrade pip \ | ||
&& pip install --no-cache /wheels/* \ | ||
&& pip install -e . \ | ||
&& wger create-settings --database-path /home/wger/db/database.sqlite \ | ||
&& wger bootstrap \ | ||
&& wger load-online-fixtures \ | ||
&& sed -i "/^MEDIA_ROOT/c\MEDIA_ROOT='\/home\/wger\/media'" settings.py \ | ||
&& echo STATIC_ROOT=\'/home/wger/static\' >> settings.py \ | ||
&& wger bootstrap --no-process-static \ | ||
&& python3 manage.py sync-exercises \ | ||
&& python3 manage.py download-exercise-images | ||
&& wger load-online-fixtures \ | ||
&& python3 manage.py download-exercise-images \ | ||
&& python3 manage.py collectstatic --no-input | ||
|
||
|
||
# Change permissions of some files and folders so the apache process | ||
# can access them. | ||
RUN mkdir -p ~/static/CACHE ~/media \ | ||
&& ln -s /home/wger/static/CACHE /home/wger/src/CACHE \ | ||
&& chmod g+w /home/wger/static/CACHE \ | ||
&& sed -i "/^MEDIA_ROOT/c\MEDIA_ROOT='\/home\/wger\/media'" settings.py \ | ||
&& echo STATIC_ROOT=\'/home/wger/static\' >> settings.py | ||
|
||
USER root | ||
RUN apt-get remove build-essential -y \ | ||
&& apt autoremove -y \ | ||
&& chown :www-data -R /home/wger/db \ | ||
RUN chown :www-data -R /home/wger/db \ | ||
&& chown www-data:www-data -R /home/wger/static \ | ||
&& chmod g+w /home/wger/db /home/wger/db/database.sqlite | ||
|
||
ENTRYPOINT ["/home/wger/entrypoint.sh"] | ||
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
# | ||
# Docker image for wger development | ||
# Docker image for wger | ||
# | ||
# Please consult the README for usage | ||
# | ||
# Note: you MUST build this image from the project's root! | ||
# docker build -f extras/docker/development/Dockerfile --tag wger/server . | ||
# docker build -f extras/docker/production/Dockerfile --tag wger/server . | ||
# | ||
# To run the container consult https://github.com/wger-project/docker | ||
|
||
########## | ||
# Builder | ||
########## | ||
FROM wger/base:latest as builder | ||
FROM wger/base:latest AS builder | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt update \ | ||
|
@@ -25,23 +25,32 @@ RUN apt update \ | |
libwebp-dev \ | ||
libpq-dev \ | ||
rustc \ | ||
cargo \ | ||
&& pip install --upgrade pip | ||
yarnpkg \ | ||
sassc \ | ||
cargo | ||
|
||
# Build the necessary python wheels | ||
# Note that the --mount tmpfs is a workaround for https://github.com/rust-lang/cargo/issues/8719 | ||
COPY requirements* ./ | ||
RUN --mount=type=tmpfs,target=/root/.cargo \ | ||
pip3 wheel --no-cache-dir --wheel-dir /wheels -r requirements_docker.txt | ||
pip3 wheel --no-cache-dir --wheel-dir /wheels -r requirements_docker.txt \ | ||
&& pip3 install --break-system-packages --user --no-cache-dir /wheels/* | ||
|
||
# Download and copy js and css files | ||
COPY . /home/wger/src | ||
WORKDIR /home/wger/src | ||
RUN ln -s /usr/bin/yarnpkg /usr/bin/yarn \ | ||
&& ln -s /usr/bin/sassc /usr/bin/sass \ | ||
&& yarn install \ | ||
&& yarn build:css:sass | ||
|
||
|
||
######## | ||
# Final | ||
######## | ||
FROM wger/base:latest | ||
LABEL maintainer="Roland Geider <[email protected]>" | ||
ARG DOCKER_DIR=./extras/docker/development | ||
ARG DOCKER_DIR=./extras/docker/production | ||
ENV PATH="/home/wger/.local/bin:$PATH" | ||
|
||
EXPOSE 8000 | ||
|
@@ -50,25 +59,24 @@ EXPOSE 8000 | |
# Set up the application | ||
WORKDIR /home/wger/src | ||
COPY --chown=wger:wger . /home/wger/src | ||
COPY --from=builder /wheels /wheels | ||
COPY --from=builder --chown=wger:wger /root/.local /home/wger/.local | ||
COPY --from=builder --chown=wger:wger /home/wger/src/wger/core/static/yarn /home/wger/src/wger/core/static/yarn | ||
COPY ${DOCKER_DIR}/settings.py /home/wger/src | ||
COPY ${DOCKER_DIR}/settings.py /tmp/ | ||
COPY ${DOCKER_DIR}/entrypoint.sh /home/wger/entrypoint.sh | ||
COPY ${DOCKER_DIR}/celery/beat/start /start-beat | ||
COPY ${DOCKER_DIR}/celery/worker/start /start-worker | ||
COPY ${DOCKER_DIR}/celery/flower/start /start-flower | ||
COPY ${DOCKER_DIR}/celery/start-beat /start-beat | ||
COPY ${DOCKER_DIR}/celery/start-worker /start-worker | ||
COPY ${DOCKER_DIR}/celery/start-flower /start-flower | ||
RUN chmod +x /home/wger/entrypoint.sh \ | ||
&& chmod +x /start-beat \ | ||
&& chmod +x /start-worker \ | ||
&& chmod +x /start-flower \ | ||
&& pip3 install --no-cache /wheels/* \ | ||
&& chown -R wger:wger . | ||
&& chmod +x /start-flower | ||
|
||
USER wger | ||
RUN pip3 install -e . \ | ||
RUN pip3 install --break-system-packages --user -e . \ | ||
&& mkdir ~/media \ | ||
&& mkdir ~/static \ | ||
&& mkdir ~/beat \ | ||
&& mkdir ~/db/ | ||
&& mkdir ~/db | ||
|
||
CMD ["/home/wger/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.