1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-28 19:06:12 +01:00
unleash.unleash/.github/workflows/docker_publish.yaml

63 lines
2.3 KiB
YAML
Raw Normal View History

name: Publish to dockerhub
on:
push:
branches:
- main
paths-ignore:
- website/**
workflow_call:
chore: Optimize docker build oss (#3951) ## About the changes Reduce the build time of OSS docker image from [~30m](https://github.com/Unleash/unleash/actions/workflows/docker_publish.yaml) to [under 15m](https://github.com/Unleash/unleash/actions/runs/5222180536/jobs/9427342758) 1. Build frontend outside docker multiplatform. 2. Allow `frontend/build` to be copied to the image by removing this from `.dockerignore` 3. Run with `--ignore-scripts` to avoid building the frontend on the `prepare` script, but this requires us to run all the prepare scripts manually (except the frontend build). **Note:** we need to build frontend in the `prepare` script to be able to have source code dependencies ## Manual Testing Manually downloaded from https://hub.docker.com/r/unleashorg/unleash-server/tags?page=1 and compared both `unleash` folders from main and the version built with the new process https://github.com/Unleash/unleash/actions/runs/5223078089/jobs/9429430190#step:5:48 ![Screenshot from 2023-06-10 21-11-33](https://github.com/Unleash/unleash/assets/455064/60a41739-904d-480d-8d80-bf17b7a70432) No major difference was spotted (only expected changes due to development done in main) **Command used to extract the contents:** ``` cd /tmp mkdir main && cd main docker pull unleashorg/unleash-server:main-edge-18-alpine docker export $(docker create unleashorg/unleash-server:main-edge-18-alpine) > container.tar && tar xvf container.tar mkdir ../new-process && cd ../new-process docker pull unleashorg/unleash-server:sha-ccac902-18-alpine docker export $(docker create unleashorg/unleash-server:sha-ccac902-18-alpine) > container.tar && tar xvf container.tar meld ./unleash ../main/unleash ```
2023-06-12 09:15:09 +02:00
inputs:
version:
description: "Which version to release"
type: 'string'
required: true
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: [20.13.1-alpine]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup QEmu so we can build multiplatform
uses: docker/setup-qemu-action@v2
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta configuration
chore(deps): update docker/metadata-action action to v5 (#6667) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [docker/metadata-action](https://togithub.com/docker/metadata-action) | action | major | `v4` -> `v5` | --- ### Release Notes <details> <summary>docker/metadata-action (docker/metadata-action)</summary> ### [`v5`](https://togithub.com/docker/metadata-action/compare/v4...v5) [Compare Source](https://togithub.com/docker/metadata-action/compare/v4...v5) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 7pm every weekday,before 5am every weekday" in timezone Europe/Madrid, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/Unleash/unleash). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI2MS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-10 11:10:10 +02:00
uses: docker/metadata-action@v5
id: meta
with:
images: |
unleashorg/unleash-server
tags: |
# only enabled for workflow dispatch except main (assume its a release):
type=semver,pattern={{ version }},enable=${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }},value=${{ inputs.version }}
type=semver,pattern={{ major }}.{{ minor }},enable=${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }},value=${{ inputs.version }}
type=semver,pattern={{ major }},enable=${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }},value=${{ inputs.version }}
# only enabled in main:
type=edge,prefix=main-,suffix=-${{ matrix.version }},enable=${{ github.ref == 'refs/heads/main' }}
chore: Optimize docker build oss (#3951) ## About the changes Reduce the build time of OSS docker image from [~30m](https://github.com/Unleash/unleash/actions/workflows/docker_publish.yaml) to [under 15m](https://github.com/Unleash/unleash/actions/runs/5222180536/jobs/9427342758) 1. Build frontend outside docker multiplatform. 2. Allow `frontend/build` to be copied to the image by removing this from `.dockerignore` 3. Run with `--ignore-scripts` to avoid building the frontend on the `prepare` script, but this requires us to run all the prepare scripts manually (except the frontend build). **Note:** we need to build frontend in the `prepare` script to be able to have source code dependencies ## Manual Testing Manually downloaded from https://hub.docker.com/r/unleashorg/unleash-server/tags?page=1 and compared both `unleash` folders from main and the version built with the new process https://github.com/Unleash/unleash/actions/runs/5223078089/jobs/9429430190#step:5:48 ![Screenshot from 2023-06-10 21-11-33](https://github.com/Unleash/unleash/assets/455064/60a41739-904d-480d-8d80-bf17b7a70432) No major difference was spotted (only expected changes due to development done in main) **Command used to extract the contents:** ``` cd /tmp mkdir main && cd main docker pull unleashorg/unleash-server:main-edge-18-alpine docker export $(docker create unleashorg/unleash-server:main-edge-18-alpine) > container.tar && tar xvf container.tar mkdir ../new-process && cd ../new-process docker pull unleashorg/unleash-server:sha-ccac902-18-alpine docker export $(docker create unleashorg/unleash-server:sha-ccac902-18-alpine) > container.tar && tar xvf container.tar meld ./unleash ../main/unleash ```
2023-06-12 09:15:09 +02:00
# only enabled on workflow_dispatch:
type=sha,suffix=-${{ matrix.version }},enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Login to docker hub
chore(deps): update docker/login-action action to v3 (#6650) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [docker/login-action](https://togithub.com/docker/login-action) | action | major | `v2` -> `v3` | --- ### Release Notes <details> <summary>docker/login-action (docker/login-action)</summary> ### [`v3`](https://togithub.com/docker/login-action/compare/v2...v3) [Compare Source](https://togithub.com/docker/login-action/compare/v2...v3) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 7pm every weekday,before 5am every weekday" in timezone Europe/Madrid, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/Unleash/unleash). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI2MS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-10 11:09:48 +02:00
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
chore: Optimize docker build oss (#3951) ## About the changes Reduce the build time of OSS docker image from [~30m](https://github.com/Unleash/unleash/actions/workflows/docker_publish.yaml) to [under 15m](https://github.com/Unleash/unleash/actions/runs/5222180536/jobs/9427342758) 1. Build frontend outside docker multiplatform. 2. Allow `frontend/build` to be copied to the image by removing this from `.dockerignore` 3. Run with `--ignore-scripts` to avoid building the frontend on the `prepare` script, but this requires us to run all the prepare scripts manually (except the frontend build). **Note:** we need to build frontend in the `prepare` script to be able to have source code dependencies ## Manual Testing Manually downloaded from https://hub.docker.com/r/unleashorg/unleash-server/tags?page=1 and compared both `unleash` folders from main and the version built with the new process https://github.com/Unleash/unleash/actions/runs/5223078089/jobs/9429430190#step:5:48 ![Screenshot from 2023-06-10 21-11-33](https://github.com/Unleash/unleash/assets/455064/60a41739-904d-480d-8d80-bf17b7a70432) No major difference was spotted (only expected changes due to development done in main) **Command used to extract the contents:** ``` cd /tmp mkdir main && cd main docker pull unleashorg/unleash-server:main-edge-18-alpine docker export $(docker create unleashorg/unleash-server:main-edge-18-alpine) > container.tar && tar xvf container.tar mkdir ../new-process && cd ../new-process docker pull unleashorg/unleash-server:sha-ccac902-18-alpine docker export $(docker create unleashorg/unleash-server:sha-ccac902-18-alpine) > container.tar && tar xvf container.tar meld ./unleash ../main/unleash ```
2023-06-12 09:15:09 +02:00
- name: Build frontend
run: |
yarn --cwd ./frontend install
yarn build:frontend
- name: Build tag and push image to Docker hub
chore(deps): update docker/build-push-action action to v5 (#6649) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [docker/build-push-action](https://togithub.com/docker/build-push-action) | action | major | `v4` -> `v5` | --- ### Release Notes <details> <summary>docker/build-push-action (docker/build-push-action)</summary> ### [`v5`](https://togithub.com/docker/build-push-action/compare/v4...v5) [Compare Source](https://togithub.com/docker/build-push-action/compare/v4...v5) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 7pm every weekday,before 5am every weekday" in timezone Europe/Madrid, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/Unleash/unleash). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI2MS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-10 11:09:28 +02:00
uses: docker/build-push-action@v5
with:
chore: Optimize docker build oss (#3951) ## About the changes Reduce the build time of OSS docker image from [~30m](https://github.com/Unleash/unleash/actions/workflows/docker_publish.yaml) to [under 15m](https://github.com/Unleash/unleash/actions/runs/5222180536/jobs/9427342758) 1. Build frontend outside docker multiplatform. 2. Allow `frontend/build` to be copied to the image by removing this from `.dockerignore` 3. Run with `--ignore-scripts` to avoid building the frontend on the `prepare` script, but this requires us to run all the prepare scripts manually (except the frontend build). **Note:** we need to build frontend in the `prepare` script to be able to have source code dependencies ## Manual Testing Manually downloaded from https://hub.docker.com/r/unleashorg/unleash-server/tags?page=1 and compared both `unleash` folders from main and the version built with the new process https://github.com/Unleash/unleash/actions/runs/5223078089/jobs/9429430190#step:5:48 ![Screenshot from 2023-06-10 21-11-33](https://github.com/Unleash/unleash/assets/455064/60a41739-904d-480d-8d80-bf17b7a70432) No major difference was spotted (only expected changes due to development done in main) **Command used to extract the contents:** ``` cd /tmp mkdir main && cd main docker pull unleashorg/unleash-server:main-edge-18-alpine docker export $(docker create unleashorg/unleash-server:main-edge-18-alpine) > container.tar && tar xvf container.tar mkdir ../new-process && cd ../new-process docker pull unleashorg/unleash-server:sha-ccac902-18-alpine docker export $(docker create unleashorg/unleash-server:sha-ccac902-18-alpine) > container.tar && tar xvf container.tar meld ./unleash ../main/unleash ```
2023-06-12 09:15:09 +02:00
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: NODE_VERSION=${{ matrix.version }}