From be780292fb666bc16dec469a4d6dd4e24b03f2c9 Mon Sep 17 00:00:00 2001 From: Victor Fernandez de Alba Date: Tue, 26 Mar 2024 09:03:10 +0100 Subject: [PATCH 1/2] New project-less image build --- Makefile | 15 +++++++++++++++ next/.npmrc | 6 ++++++ next/Dockerfile | 19 +++++++++++++++++++ next/Dockerfile.builder | 39 +++++++++++++++++++++++++++++++++++++++ next/Dockerfile.prod | 39 +++++++++++++++++++++++++++++++++++++++ next/mrs.developer.json | 9 +++++++++ next/package.json | 13 +++++++++++++ next/pnpm-workspace.yaml | 6 ++++++ next/volto.config.js | 7 +++++++ 9 files changed, 153 insertions(+) create mode 100644 next/.npmrc create mode 100644 next/Dockerfile create mode 100644 next/Dockerfile.builder create mode 100644 next/Dockerfile.prod create mode 100644 next/mrs.developer.json create mode 100644 next/package.json create mode 100644 next/pnpm-workspace.yaml create mode 100644 next/volto.config.js diff --git a/Makefile b/Makefile index 9c1804b..37b1bfe 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,11 @@ image-builder: ## Build Base Image @echo "Building $(BASE_IMAGE_NAME)-builder:$(IMAGE_TAG)" @docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(BASE_IMAGE_NAME)-builder:$(IMAGE_TAG) -f Dockerfile.builder --load +.PHONY: image-builder-next +image-builder-next: ## Build Base Image + @echo "Building $(BASE_IMAGE_NAME)-builder-next:$(IMAGE_TAG)" + @docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(BASE_IMAGE_NAME)-builder-next:$(IMAGE_TAG) -f next/Dockerfile.builder --load + .PHONY: image-dev image-dev: ## Build Dev Image @echo "Building $(BASE_IMAGE_NAME)-dev:$(IMAGE_TAG)" @@ -78,11 +83,21 @@ image-prod-config: ## Build Prod Image @echo "Building $(BASE_IMAGE_NAME)-prod-config:$(IMAGE_TAG)" @docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(BASE_IMAGE_NAME)-prod-config:$(IMAGE_TAG) -f Dockerfile.prod --load +.PHONY: image-prod-config-next +image-prod-config-next: ## Build Prod Image + @echo "Building $(BASE_IMAGE_NAME)-prod-config:$(IMAGE_TAG)" + @docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(BASE_IMAGE_NAME)-prod-config-next:$(IMAGE_TAG) -f next/Dockerfile.prod --load + .PHONY: image-main image-main: ## Build main image @echo "Building $(MAIN_IMAGE_NAME):$(IMAGE_TAG)" @docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(MAIN_IMAGE_NAME):$(IMAGE_TAG) -f Dockerfile --load +.PHONY: image-main-next +image-main-next: ## Build main image + @echo "Building $(MAIN_IMAGE_NAME):$(IMAGE_TAG)" + @docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(MAIN_IMAGE_NAME):$(IMAGE_TAG) -f next/Dockerfile --load + .PHONY: image-nightly image-nightly: ## Build Docker Image Nightly @echo "Building $(MAIN_IMAGE_NAME):$(NIGHTLY_IMAGE_TAG)" diff --git a/next/.npmrc b/next/.npmrc new file mode 100644 index 0000000..71c6843 --- /dev/null +++ b/next/.npmrc @@ -0,0 +1,6 @@ +public-hoist-pattern[]=*eslint* +public-hoist-pattern[]=*prettier* +public-hoist-pattern[]=*stylelint* +public-hoist-pattern[]=*cypress* +public-hoist-pattern[]=*process* +public-hoist-pattern[]=*parcel* diff --git a/next/Dockerfile b/next/Dockerfile new file mode 100644 index 0000000..9b0ffb0 --- /dev/null +++ b/next/Dockerfile @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1 +ARG VOLTO_VERSION +FROM plone/frontend-builder-next:${VOLTO_VERSION} as builder + +# Build Volto Project and then remove directories not needed for production +RUN < Date: Tue, 26 Mar 2024 09:12:17 +0100 Subject: [PATCH 2/2] Add dev image and fix Makefile --- .github/workflows/release-next.yml | 94 ++++++++++++++++++++++++++++++ Makefile | 7 ++- next/Dockerfile.dev | 19 ++++++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-next.yml create mode 100644 next/Dockerfile.dev diff --git a/.github/workflows/release-next.yml b/.github/workflows/release-next.yml new file mode 100644 index 0000000..ad29e70 --- /dev/null +++ b/.github/workflows/release-next.yml @@ -0,0 +1,94 @@ +name: Release new Docker image + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +env: + BASE_IMAGE_NAME: plone/frontend + PLATFORMS: linux/amd64,linux/arm64 + IS_LATEST: false + +jobs: + + meta: + runs-on: ubuntu-latest + outputs: + BASE_IMAGE_NAME: ${{ steps.vars.outputs.BASE_IMAGE_NAME }} + IS_LATEST: ${{ steps.vars.outputs.IS_LATEST }} + PLATFORMS: ${{ steps.vars.outputs.PLATFORMS }} + VOLTO_VERSION: ${{ steps.vars.outputs.VOLTO_VERSION }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set BASE_IMAGE_NAME, IS_LATEST, PLATFORMS, VOLTO_VERSION + id: vars + run: | + echo "BASE_IMAGE_NAME=$BASE_IMAGE_NAME" >> $GITHUB_OUTPUT + echo "PLATFORMS=$PLATFORMS" >> $GITHUB_OUTPUT + echo "IS_LATEST=$IS_LATEST" >> $GITHUB_OUTPUT + echo "VOLTO_VERSION=$(cat version.txt)" >> $GITHUB_OUTPUT + + builder-image: + needs: + - meta + uses: ./.github/workflows/image-release.yml + with: + volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }} + image-name: ${{ needs.meta.outputs.BASE_IMAGE_NAME }}-builder-next + dockerfile: next/Dockerfile.builder + platforms: ${{ needs.meta.outputs.PLATFORMS }} + is-latest: ${{ needs.meta.outputs.IS_LATEST == 'true' }} + secrets: + registry-username: ${{ secrets.DOCKERHUB_USERNAME }} + registry-password: ${{ secrets.DOCKERHUB_TOKEN }} + + prod-conf-image: + uses: ./.github/workflows/image-release.yml + with: + volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }} + image-name: ${{ needs.meta.outputs.BASE_IMAGE_NAME }}-prod-config-next + dockerfile: next/Dockerfile.prod + platforms: ${{ needs.meta.outputs.PLATFORMS }} + is-latest: ${{ needs.meta.outputs.IS_LATEST == 'true' }} + + secrets: + registry-username: ${{ secrets.DOCKERHUB_USERNAME }} + registry-password: ${{ secrets.DOCKERHUB_TOKEN }} + needs: + - meta + + dev-image: + uses: ./.github/workflows/image-release.yml + with: + volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }} + image-name: ${{ needs.meta.outputs.BASE_IMAGE_NAME }}-dev-next + dockerfile: next/Dockerfile.dev + platforms: ${{ needs.meta.outputs.PLATFORMS }} + is-latest: ${{ needs.meta.outputs.IS_LATEST == 'true' }} + secrets: + registry-username: ${{ secrets.DOCKERHUB_USERNAME }} + registry-password: ${{ secrets.DOCKERHUB_TOKEN }} + needs: + - meta + - builder-image + + plone-frontend: + uses: ./.github/workflows/image-release.yml + with: + volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }} + image-name: plone/plone-frontend-next + dockerfile: next/Dockerfile + platforms: ${{ needs.meta.outputs.PLATFORMS }} + is-latest: ${{ needs.meta.outputs.IS_LATEST == 'true' }} + secrets: + registry-username: ${{ secrets.DOCKERHUB_USERNAME }} + registry-password: ${{ secrets.DOCKERHUB_TOKEN }} + needs: + - meta + - builder-image + - prod-conf-image diff --git a/Makefile b/Makefile index 37b1bfe..4ebed4c 100644 --- a/Makefile +++ b/Makefile @@ -78,6 +78,11 @@ image-dev: ## Build Dev Image @echo "Building $(BASE_IMAGE_NAME)-dev:$(IMAGE_TAG)" @docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(BASE_IMAGE_NAME)-dev:$(IMAGE_TAG) -f Dockerfile.dev --load +.PHONY: image-dev-next +image-dev-next: ## Build Dev Image + @echo "Building $(BASE_IMAGE_NAME)-dev:$(IMAGE_TAG)" + @docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(BASE_IMAGE_NAME)-dev-next:$(IMAGE_TAG) -f next/Dockerfile.dev --load + .PHONY: image-prod-config image-prod-config: ## Build Prod Image @echo "Building $(BASE_IMAGE_NAME)-prod-config:$(IMAGE_TAG)" @@ -96,7 +101,7 @@ image-main: ## Build main image .PHONY: image-main-next image-main-next: ## Build main image @echo "Building $(MAIN_IMAGE_NAME):$(IMAGE_TAG)" - @docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(MAIN_IMAGE_NAME):$(IMAGE_TAG) -f next/Dockerfile --load + @docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(MAIN_IMAGE_NAME)-next:$(IMAGE_TAG) -f next/Dockerfile --load .PHONY: image-nightly image-nightly: ## Build Docker Image Nightly diff --git a/next/Dockerfile.dev b/next/Dockerfile.dev new file mode 100644 index 0000000..27fed55 --- /dev/null +++ b/next/Dockerfile.dev @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1 +ARG VOLTO_VERSION +FROM plone/frontend-builder-next:${VOLTO_VERSION} + +LABEL maintainer="Plone Community " \ + org.label-schema.name="frontend-dev" \ + org.label-schema.description="Plone frontend image for development" \ + org.label-schema.vendor="Plone Foundation" + +WORKDIR /app + +# Expose ports 3000 and 3001 (used by Express in development mode) and port 6006 (Storybook) +EXPOSE 3000 3001 6006 + +# Entrypoint would be yarn +ENTRYPOINT [ "pnpm" ] + +# Run the project in development mode +CMD ["start"]