From 241fae07a250dfbeee9ee022cdbec9b589cb906a Mon Sep 17 00:00:00 2001 From: Aliaksandr Shulyak Date: Sat, 30 Apr 2022 21:41:05 -0500 Subject: [PATCH] Build improvements --- ...er.yaml => build-and-push-base-image.yaml} | 29 ++++++++++----- .gitignore | 1 + Dockerfile | 36 +++---------------- Dockerfile.base | 28 +++++++++++++++ package.json | 4 ++- 5 files changed, 57 insertions(+), 41 deletions(-) rename .github/workflows/{docker.yaml => build-and-push-base-image.yaml} (55%) create mode 100644 Dockerfile.base diff --git a/.github/workflows/docker.yaml b/.github/workflows/build-and-push-base-image.yaml similarity index 55% rename from .github/workflows/docker.yaml rename to .github/workflows/build-and-push-base-image.yaml index 92eecab..3ba7d17 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/build-and-push-base-image.yaml @@ -1,31 +1,44 @@ -name: Build and Publish docker image to ghcr +name: Build and push base docker image on: - release: - types: [created] + push: + paths: + - ./Dockerfile.base + branches: + - master + +env: + alpine_version: 3.15 jobs: - docker: + build-and-push-base-image: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + - name: Set up QEMU uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push uses: docker/build-push-action@v2 with: context: . platforms: linux/amd64,linux/arm64,linux/arm/v7 + file: Dockerfile.base + build_args: + - ALPINE_VERSION=${{ env.alpine_version }} push: true tags: | - ghcr.io/thelonkarrde/planka:latest - ghcr.io/thelonkarrde/planka:${{ github.event.release.tag_name }} + ghcr.io/plankanban/planka:build-base-latest + ghcr.io/plankanban/planka:build-base-${{ env.alpine_version }} diff --git a/.gitignore b/.gitignore index b962ee7..f1f0dc3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules docker-compose.override.yml +.idea .vscode .DS_Store diff --git a/Dockerfile b/Dockerfile index f6e6520..05c10bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,47 +10,19 @@ RUN npm install npm@latest --global \ COPY client . RUN npm run build -FROM node:lts-alpine +FROM ghcr.io/plankanban/planka:base WORKDIR /app COPY server/.npmrc server/package.json server/package-lock.json ./ -ARG ALPINE_VERSION=3.15 -ARG VIPS_VERSION=8.12.2 - -RUN apk -U upgrade \ - && apk add \ - bash giflib glib lcms2 libexif \ - libgsf libjpeg-turbo libpng librsvg libwebp \ - orc pango tiff \ - --repository https://alpine.global.ssl.fastly.net/alpine/v${ALPINE_VERSION}/community/ \ - --repository https://alpine.global.ssl.fastly.net/alpine/v${ALPINE_VERSION}/main/ \ - --no-cache \ - && apk add \ - build-base giflib-dev glib-dev lcms2-dev libexif-dev \ - libgsf-dev libjpeg-turbo-dev libpng-dev librsvg-dev libwebp-dev \ - orc-dev pango-dev tiff-dev \ - --virtual vips-dependencies \ - --repository https://alpine.global.ssl.fastly.net/alpine/v${ALPINE_VERSION}/community/ \ - --repository https://alpine.global.ssl.fastly.net/alpine/v${ALPINE_VERSION}/main/ \ - --no-cache \ - && wget -O- https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.gz | tar xzC /tmp \ - && cd /tmp/vips-${VIPS_VERSION} \ - && ./configure \ - && make \ - && make install-strip \ - && cd $OLDPWD \ - && rm -rf /tmp/vips-${VIPS_VERSION} \ - && npm install npm@latest --global \ - && npm install --production \ - && apk del vips-dependencies --purge +RUN npm install npm@latest --global \ + && npm install --production COPY docker-start.sh start.sh COPY server . -RUN chmod +x start.sh \ - && cp .env.sample .env +RUN cp .env.sample .env COPY --from=client-builder /app/build public COPY --from=client-builder /app/build/index.html views diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..107a60e --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,28 @@ +FROM node:lts-alpine + +ARG ALPINE_VERSION=3.15 +ARG VIPS_VERSION=8.12.2 + +RUN apk -U upgrade \ + && apk add \ + bash giflib glib lcms2 libexif \ + libgsf libjpeg-turbo libpng librsvg libwebp \ + orc pango tiff \ + --repository https://alpine.global.ssl.fastly.net/alpine/v${ALPINE_VERSION}/community/ \ + --repository https://alpine.global.ssl.fastly.net/alpine/v${ALPINE_VERSION}/main/ \ + --no-cache \ + && apk add \ + build-base giflib-dev glib-dev lcms2-dev libexif-dev \ + libgsf-dev libjpeg-turbo-dev libpng-dev librsvg-dev libwebp-dev \ + orc-dev pango-dev tiff-dev \ + --virtual vips-dependencies \ + --repository https://alpine.global.ssl.fastly.net/alpine/v${ALPINE_VERSION}/community/ \ + --repository https://alpine.global.ssl.fastly.net/alpine/v${ALPINE_VERSION}/main/ \ + --no-cache \ + && wget -O- https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.gz | tar xzC /tmp \ + && cd /tmp/vips-${VIPS_VERSION} \ + && ./configure \ + && make \ + && make install-strip \ + && rm -rf /tmp/vips-${VIPS_VERSION} \ + && apk del vips-dependencies --purge \ No newline at end of file diff --git a/package.json b/package.json index 5fd9567..d1c3cd7 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,9 @@ "server:start:prod": "npm run start:prod --prefix server", "server:test": "npm test --prefix server", "start": "concurrently -n server,client \"npm run server:start\" \"npm run client:start\"", - "test": "npm run server:test && npm run client:test" + "test": "npm run server:test && npm run client:test", + "docker-build-base": "docker build -t ghcr.io/plankanban/planka:build-base -f Dockerfile.base .", + "docker-build": "docker build -t ghcr.io/plankanban/planka:build-base -f Dockerfile ." }, "lint-staged": { "client/**/*.{js,jsx}": [