Skip to content

Commit

Permalink
ci: docker build (#114)
Browse files Browse the repository at this point in the history
* ci: docker build

* ci: docker build

* add initial Dockerfile

* Update ui image node version

* Update dockerfile

* Fix ui docker build

* Update ui image name

* chore: license header

---------

Co-authored-by: lubnar <[email protected]>
Co-authored-by: Lubnar <[email protected]>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent 4bcee6c commit ae26c05
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 19 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build-ui-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2024 grow platform GmbH
#
# SPDX-License-Identifier: MIT

on:
workflow_call:

jobs:
build-ui-docker-image:
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: b-s-f/yaku/ui
steps:
- uses: actions/checkout@v4

- name: Log in to the Container Registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate image tag
run: |
base_tag="${{ env.IMAGE_NAME }}:$( date '+%Y-%m-%d_%H-%M-%S' )-$(echo ${GITHUB_SHA} | cut -c1-7)"
image_tag="${{ env.REGISTRY }}/$base_tag"
echo "IMAGE_TAG=$image_tag" >> $GITHUB_ENV
- name: Build Docker Image
uses: docker/build-push-action@v5
with:
pull: true
push: true
tags: ${{ env.IMAGE_TAG }}
context: ./yaku-ui
file: yaku-ui/Dockerfile
platforms: linux/amd64
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ jobs:
- build-backend
uses: ./.github/workflows/build-backend-docker-image.yml

build-ui-docker-image:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
needs:
- build-ui
uses: ./.github/workflows/build-ui-docker-image.yml

build-core-docker-image:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
needs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ node_modules
/.pants.d/

yaku-apps-typescript/apps/defender-for-cloud/results.json
/yaku-ui/.turbo/**
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ cypress
reports
.github/**
.vscode/**
.turbo/**
33 changes: 15 additions & 18 deletions yaku-ui/qg-service-ui/Dockerfile → yaku-ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# PRODUCTION
#############

ARG BASE_IMAGE_NODEJS_NAME="node:18-alpine"
ARG BASE_IMAGE_NODEJS_NAME="node:20-alpine"
ARG BASE_IMAGE_NGINX_NAME="nginx:1.27.2-alpine-slim"
FROM ${BASE_IMAGE_NODEJS_NAME} as app-builder

ARG VITE_TEST_RUN_FEATURE
ARG VITE_TEST_RELEASE_PLANNING_FEATURE
ARG VITE_TEST_RELEASE_EMAILS
ARG VITE_TEST_TASK_MANAGEMENT
ARG VITE_TEST_VUETIFY_UI
ARG VITE_TEST_RUN_FEATURE="true"
ARG VITE_TEST_RELEASE_PLANNING_FEATURE="true"
ARG VITE_TEST_RELEASE_EMAILS="true"
ARG VITE_TEST_TASK_MANAGEMENT="true"
ARG VITE_TEST_VUETIFY_UI="true"

ENV NODE_ENV=development

Expand All @@ -30,24 +30,22 @@ ENV PATH=$PATH:$APP_USER_HOME/node_modules/.bin
USER ${APP_USER_NAME}
WORKDIR ${APP_USER_HOME}/app

COPY --chown=${APP_USER_NAME}:${APP_USER_NAME} package.json package-lock.json .

RUN --mount=type=secret,id=npmrc,target=${APP_USER_HOME}/.npmrc,uid=${APP_USER_ID} npm ci --ignore-scripts
COPY --chown=${APP_USER_NAME}:${APP_USER_NAME} . .
RUN npm ci --ignore-scripts

RUN --mount=type=secret,id=npmrc,target=${APP_USER_HOME}/.npmrc,uid=${APP_USER_ID} npm rebuild node-sass && NODE_OPTIONS=--max-old-space-size=8192 npm run build
RUN npm rebuild node-sass && NODE_OPTIONS=--max-old-space-size=8192 npm run build


FROM ${BASE_IMAGE_NGINX_NAME} as production

LABEL maintainer="Neutrinos GROW/PAT"
LABEL description="YAKU ui docker image based on nginx:1.27.2-alpine-slim"

ARG VITE_TEST_RUN_FEATURE
ARG VITE_TEST_RELEASE_PLANNING_FEATURE
ARG VITE_TEST_RELEASE_EMAILS
ARG VITE_TEST_TASK_MANAGEMENT
ARG VITE_TEST_VUETIFY_UI
ARG VITE_TEST_RUN_FEATURE="true"
ARG VITE_TEST_RELEASE_PLANNING_FEATURE="true"
ARG VITE_TEST_RELEASE_EMAILS="true"
ARG VITE_TEST_TASK_MANAGEMENT="true"
ARG VITE_TEST_VUETIFY_UI="true"

USER root

Expand All @@ -62,9 +60,8 @@ ENV NGINX_PORT=8080

WORKDIR ${APP_USER_HOME}/app

COPY --from=app-builder ${APP_USER_HOME}/app/dist /usr/share/nginx/html/
COPY --from=app-builder ${APP_USER_HOME}/app/package.json package.json
COPY --chown=nginx:nginx ./.docker/default.conf.template /etc/nginx/conf.d/default.conf
COPY --chown=${APP_USER_NAME}:${APP_USER_NAME} --from=app-builder ${APP_USER_HOME}/app/qg-service-ui/dist /usr/share/nginx/html/
COPY --chown=nginx:nginx ./qg-service-ui/.docker/default.conf.template /etc/nginx/conf.d/default.conf

USER root

Expand Down
2 changes: 1 addition & 1 deletion yaku-ui/qg-service-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dev:test": "vite --mode dev:mock --port 4999",
"check": "vue-tsc --noEmit",
"build": "vite build",
"docker:build": "docker-buildx build . -t qg-aas-ui:latest --secret id=npmrc,src=.npmrc --secret id=env,src=.env.local",
"docker:build": "docker-buildx build . -t qg-aas-ui:latest",
"docker:start": "docker run -it --mount=type=bind,src=./ui-dev-config.json,dst=/home/node/app/dist/ui-config.json,readonly=true -p 3000:3000 qg-aas-ui:latest",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
Expand Down

0 comments on commit ae26c05

Please sign in to comment.