From 6560babe7614f6b9f6551113366a290151c8b178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Piotrowski?= Date: Tue, 4 Feb 2025 22:45:10 +0100 Subject: [PATCH] docker: Merge Dockerfiles into one again --- .github/workflows/backend_base_images.yml | 55 ----------------------- backend/Dockerfile | 36 ++++++++++++--- backend/Dockerfile.base | 13 ------ backend/Dockerfile.builder-base | 19 -------- 4 files changed, 30 insertions(+), 93 deletions(-) delete mode 100644 .github/workflows/backend_base_images.yml delete mode 100644 backend/Dockerfile.base delete mode 100644 backend/Dockerfile.builder-base diff --git a/.github/workflows/backend_base_images.yml b/.github/workflows/backend_base_images.yml deleted file mode 100644 index b5c5f02c2..000000000 --- a/.github/workflows/backend_base_images.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: 🐋 Build backend base images - -on: - schedule: - - cron: "0 0 * * 0" - workflow_dispatch: - -jobs: - build-base-images: - strategy: - matrix: - include: - - os: ubuntu-24.04 - platform: amd64 - - os: ubuntu-24.04-arm - platform: arm64 - runs-on: ${{matrix.os}} - permissions: - packages: write - steps: - - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to ghcr.io - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push builder-base - uses: docker/build-push-action@v6 - with: - context: backend - file: backend/Dockerfile.builder-base - push: true - tags: | - ghcr.io/flathub-infra/backend-builder-base:latest - platforms: linux/${{ matrix.platform }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Build and push base - uses: docker/build-push-action@v6 - with: - context: backend - file: backend/Dockerfile.base - push: true - tags: | - ghcr.io/flathub-infra/backend-base:latest - platforms: linux/${{ matrix.platform }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/backend/Dockerfile b/backend/Dockerfile index 019f98f0f..a5a7a0eb6 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,21 +1,45 @@ -FROM ghcr.io/flathub-infra/backend-builder-base:latest AS builder +FROM ubuntu:latest AS builder -COPY pyproject.toml poetry.lock / +RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common \ + && add-apt-repository ppa:flatpak/stable + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + python3 python3-dev python3-pip python-is-python3 python3-venv \ + build-essential libpq-dev libcairo2-dev libgirepository1.0-dev \ + gir1.2-ostree-1.0 gir1.2-appstream-1.0 flatpak + +RUN python -m pip install --no-cache-dir --break-system-packages pipx && \ + pipx install poetry && \ + pipx inject poetry poetry-plugin-export +COPY pyproject.toml poetry.lock / RUN /root/.local/bin/poetry export -f requirements.txt --output requirements.txt && \ python -m venv /venv && \ /venv/bin/python -m pip install --no-cache-dir -r requirements.txt -FROM ghcr.io/flathub-infra/backend-base:latest +FROM ubuntu:latest ARG SENTRY_RELEASE -ENV PATH="/venv/bin:$PATH" -EXPOSE 8000 +RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common \ + && add-apt-repository ppa:flatpak/stable + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + python3 python-is-python3 python3-venv ca-certificates libcairo2 libpq5 \ + libgirepository-1.0-1 gir1.2-ostree-1.0 gir1.2-appstream-1.0 flatpak && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +RUN flatpak --user remote-add flathub https://flathub.org/repo/flathub.flatpakrepo && \ + flatpak --user remote-add flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo COPY --from=builder /venv /venv COPY . /app WORKDIR /app -ENV SENTRY_RELEASE="$SENTRY_RELEASE" +ENV PATH="/venv/bin:$PATH" \ + SENTRY_RELEASE="$SENTRY_RELEASE" + +EXPOSE 8000 CMD ["/app/docker-entrypoint.sh"] diff --git a/backend/Dockerfile.base b/backend/Dockerfile.base deleted file mode 100644 index 773576a38..000000000 --- a/backend/Dockerfile.base +++ /dev/null @@ -1,13 +0,0 @@ -FROM ubuntu:latest - -RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common \ - && add-apt-repository ppa:flatpak/stable - -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - python3 python-is-python3 python3-venv ca-certificates libcairo2 libpq5 \ - libgirepository-1.0-1 gir1.2-ostree-1.0 gir1.2-appstream-1.0 flatpak && \ - apt-get clean && rm -rf /var/lib/apt/lists/* - -RUN flatpak --user remote-add flathub https://flathub.org/repo/flathub.flatpakrepo && \ - flatpak --user remote-add flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo \ No newline at end of file diff --git a/backend/Dockerfile.builder-base b/backend/Dockerfile.builder-base deleted file mode 100644 index 7681f47cc..000000000 --- a/backend/Dockerfile.builder-base +++ /dev/null @@ -1,19 +0,0 @@ -FROM ubuntu:latest - -RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common \ - && add-apt-repository ppa:flatpak/stable - -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - python3 python3-dev python3-pip python-is-python3 python3-venv build-essential libpq-dev libcairo2-dev libgirepository1.0-dev \ - gir1.2-ostree-1.0 gir1.2-appstream-1.0 flatpak - -RUN python -m pip install --no-cache-dir --break-system-packages pipx && \ - pipx install poetry && \ - pipx inject poetry poetry-plugin-export - -COPY pyproject.toml poetry.lock / -RUN /root/.local/bin/poetry export -f requirements.txt --output requirements.txt && \ - python -m venv /venv && \ - /venv/bin/python -m pip install --no-cache-dir -r requirements.txt && \ - rm -f /pyproject.toml /poetry.lock /requirements.txt