Skip to content

Commit

Permalink
Fix Docker image creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ericof committed Jul 15, 2024
1 parent 4ee1ade commit 7c95565
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 41 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,32 +139,3 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PLONE_VERSION=${{ needs.config.outputs.PLONE_VERSION }}
- name: Docker meta
id: meta-demo
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_NAME_PREFIX }}-demo
labels: |
org.label-schema.docker.cmd=docker run -d -p 8080:8080 ${{ env.IMAGE_NAME_PREFIX }}-demo:latest
flavor:
latest=false
tags: |
type=ref,event=branch
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push demo
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
context: backend
file: backend/Dockerfile.demo
load: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-demo.outputs.tags }}
labels: ${{ steps.meta-demo.outputs.labels }}
build-args: |
SEED=${{ github.run_id }}
IMAGE_TAG=${{ needs.config.outputs.BASE_TAG }}
15 changes: 6 additions & 9 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
ARG PLONE_VERSION=6.0.11
FROM plone/server-builder:${PLONE_VERSION} as builder
FROM plone/server-builder:${PLONE_VERSION} AS builder

WORKDIR /app

Expand All @@ -12,24 +12,21 @@ COPY . src
# Install local requirements and pre-compile mo files
RUN <<EOT
set -e
bin/pip install mxdev uv
mv src/requirements-docker.txt src/requirements.txt
sed -i 's/-e .\[test\]/./g' src/mx.ini
bin/pip install mxdev uv hatch
cd /app/src
# remove potentially existing virtualenv from local build
rm -rf .venv
../bin/hatch build
../bin/mxdev -c mx.ini
../bin/uv pip install -r requirements-mxdev.txt
../bin/uv pip install dist/*.whl -c constraints-mxdev.txt
../bin/python /compile_mo.py
cd /app
rm -Rf src/
rm -Rf /app/src
EOT

FROM plone/server-prod-config:${PLONE_VERSION}

LABEL maintainer="Plone Foundation <[email protected]>" \
org.label-schema.name="volto-form-block-backend" \
org.label-schema.description="Project Title backend image." \
org.label-schema.description="Volto Form Block: Backend" \
org.label-schema.vendor="Plone Foundation"

# Copy /app from builder
Expand Down
3 changes: 0 additions & 3 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ test-coverage: $(BIN_FOLDER)/pytest ## run tests with coverage
.PHONY: build-image
build-image: ## Build Docker Images
@DOCKER_BUILDKIT=1 docker build . -t $(IMAGE_NAME_PREFIX)-backend:$(IMAGE_TAG) -f Dockerfile --build-arg PLONE_VERSION=$(PLONE_VERSION)
@echo "$(GREEN)==> Building $(IMAGE_NAME_PREFIX)-demo:$(IMAGE_TAG) $(RESET)"
@DOCKER_BUILDKIT=1 docker build . --pull=false -t $(IMAGE_NAME_PREFIX)-demo:$(IMAGE_TAG) -f Dockerfile.demo --build-arg IMAGE_TAG=$(IMAGE_TAG) --build-arg SEED=$(SEED)


# Acceptance tests
.PHONY: acceptance-backend-start
Expand Down
31 changes: 31 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# syntax=docker/dockerfile:1
ARG VOLTO_VERSION
# TODO: Replace with
# FROM plone/frontend-builder:${VOLTO_VERSION}
# when the main image is ready
FROM ghcr.io/kitconcept/frontend-builder:${VOLTO_VERSION} AS builder

COPY --chown=node packages/volto-form-block /app/packages/volto-form-block
COPY --chown=node volto.config.js /app/
COPY --chown=node package.json /app/package.json.temp

RUN --mount=type=cache,id=pnpm,target=/app/.pnpm-store,uid=1000 <<EOT
set -e
python3 -c "import json; data = json.load(open('package.json.temp')); deps = data['dependencies']; data['dependencies'].update(deps); json.dump(data, open('package.json', 'w'), indent=2)"
rm package.json.temp
pnpm install && pnpm build:deps
pnpm build
pnpm install --prod
EOT

# TODO: Replace with
# FROM plone/frontend-prod-config:${VOLTO_VERSION}
# when the main image is ready
FROM ghcr.io/kitconcept/frontend-prod-config:${VOLTO_VERSION}

LABEL maintainer="Plone Collective <[email protected]>" \
org.label-schema.name="ghcr.io/collective/volto-form-block-frontend" \
org.label-schema.description="Volto Form Block" \
org.label-schema.vendor="Plone Collective"

COPY --from=builder /app/ /app/

0 comments on commit 7c95565

Please sign in to comment.