Skip to content

New project-less image build #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/release-next.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,41 @@ 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)"
@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)"
@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)-next:$(IMAGE_TAG) -f next/Dockerfile --load

.PHONY: image-nightly
image-nightly: ## Build Docker Image Nightly
@echo "Building $(MAIN_IMAGE_NAME):$(NIGHTLY_IMAGE_TAG)"
Expand Down
6 changes: 6 additions & 0 deletions next/.npmrc
Original file line number Diff line number Diff line change
@@ -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*
19 changes: 19 additions & 0 deletions next/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <<EOT
set -e
pnpm build
EOT

FROM plone/frontend-prod-config-next:${VOLTO_VERSION} as base

LABEL maintainer="Plone Community <[email protected]>" \
org.label-schema.name="plone-frontend" \
org.label-schema.description="Plone frontend image" \
org.label-schema.vendor="Plone Foundation"

# Copy Volto project
COPY --from=builder /app/ /app/
39 changes: 39 additions & 0 deletions next/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# syntax=docker/dockerfile:1
FROM node:20-slim
ARG VOLTO_VERSION
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

LABEL maintainer="Plone Community <[email protected]>" \
org.label-schema.name="frontend-base" \
org.label-schema.description="Plone frontend builder image" \
org.label-schema.vendor="Plone Foundation"

RUN <<EOT
set -e
apt update
apt install -y --no-install-recommends python3 build-essential git ca-certificates
npm install --no-audit --no-fund -g mrs-developer
mkdir /app
chown -R node:node /app
rm -rf /var/lib/apt/lists/*
EOT

WORKDIR /app
RUN corepack enable

USER node
COPY --chown=node:node next/mrs.developer.json /app/.
COPY --chown=node:node next/pnpm-workspace.yaml /app/.
COPY --chown=node:node next/package.json /app/.
COPY --chown=node:node next/.npmrc /app/.
COPY --chown=node:node next/volto.config.js /app/.

RUN <<EOT
set -e
sed -i 's/${VOLTO_VERSION}/'"$VOLTO_VERSION"'/g' mrs.developer.json
missdev --no-config --fetch-https
mkdir packages
EOT

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install
19 changes: 19 additions & 0 deletions next/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# syntax=docker/dockerfile:1
ARG VOLTO_VERSION
FROM plone/frontend-builder-next:${VOLTO_VERSION}

LABEL maintainer="Plone Community <[email protected]>" \
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"]
39 changes: 39 additions & 0 deletions next/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# syntax=docker/dockerfile:1
FROM node:20-slim

LABEL maintainer="Plone Community <[email protected]>" \
org.label-schema.name="frontend-prod-config" \
org.label-schema.description="Slim image for Plone frontend deployments" \
org.label-schema.vendor="Plone Foundation"


# Install busybox and wget
RUN <<EOT
set -e
apt update
apt install -y --no-install-recommends busybox wget git
busybox --install -s
rm -rf /var/lib/apt/lists/*
mkdir /app
chown -R node:node /app
EOT

RUN corepack enable

# Run the image with user node
USER node

# Set working directory to /app
WORKDIR /app

# Expose default Express port
EXPOSE 3000

# Set healthcheck to port 3000
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s CMD [ -n "$LISTEN_PORT" ] || LISTEN_PORT=3000 ; wget -q http://127.0.0.1:"$LISTEN_PORT" -O - || exit 1

# Entrypoint would be pnpm
ENTRYPOINT [ "pnpm" ]

# And the image will run in production mode
CMD ["start:prod"]
9 changes: 9 additions & 0 deletions next/mrs.developer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"core": {
"output": "./",
"package": "@plone/volto",
"url": "[email protected]:plone/volto.git",
"https": "https://github.com/plone/volto.git",
"tag": "${VOLTO_VERSION}"
}
}
13 changes: 13 additions & 0 deletions next/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "builder-next",
"scripts": {
"start:prod": "pnpm --filter @plone/volto start:prod",
"build": "pnpm build:deps && VOLTOCONFIG=$(pwd)/volto.config.js pnpm --filter @plone/volto build",
"build:deps": "pnpm --filter @plone/registry --filter @plone/components build"
},
"dependencies": {
"@plone/volto": "workspace:*",
"@plone/registry": "workspace:*"
},
"packageManager": "[email protected]"
}
6 changes: 6 additions & 0 deletions next/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
packages:
- 'core/packages/*'
- 'packages/volto-light-theme'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be here?

# This is for the packages in nested subdirs of packages/
# (already moved to the new project-less setup)
- 'packages/**/packages/*'
7 changes: 7 additions & 0 deletions next/volto.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const addons = [];
const theme = "";

module.exports = {
addons,
theme,
};