updated build
This commit is contained in:
parent
2361fa7b92
commit
0afd119bdb
6 changed files with 83 additions and 83 deletions
3
.github/workflows/local-build-push.yaml
vendored
3
.github/workflows/local-build-push.yaml
vendored
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
name: local-build
|
name: local-build
|
||||||
run-name: local-build ${{ github.actor }}
|
run-name: local-build ${{ github.actor }}
|
||||||
on:
|
on:
|
||||||
|
|
@ -55,6 +54,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
context: cms
|
context: cms
|
||||||
load: true
|
load: true
|
||||||
|
file: docker/Dockerfile
|
||||||
# cache-from: type=gha
|
# cache-from: type=gha
|
||||||
# cache-to: type=gha,mode=max
|
# cache-to: type=gha,mode=max
|
||||||
# cache-from: type=local,src=/tmp/.buildx-cache
|
# cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
|
@ -76,4 +76,3 @@ jobs:
|
||||||
docker-compose pull
|
docker-compose pull
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
||||||
|
|
||||||
|
|
|
||||||
2
.github/workflows/local-build.yaml
vendored
2
.github/workflows/local-build.yaml
vendored
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
name: local-build
|
name: local-build
|
||||||
run-name: local-build ${{ github.actor }}
|
run-name: local-build ${{ github.actor }}
|
||||||
on:
|
on:
|
||||||
|
|
@ -47,6 +46,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
context: cms
|
context: cms
|
||||||
load: true
|
load: true
|
||||||
|
file: docker/Dockerfile
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
# cache-from: type=local,src=/tmp/.buildx-cache
|
# cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
|
|
||||||
145
.github/workflows/release.yaml
vendored
145
.github/workflows/release.yaml
vendored
|
|
@ -1,78 +1,79 @@
|
||||||
name: release
|
name: release
|
||||||
run-name: release ${{ github.actor }}
|
run-name: release ${{ github.actor }}
|
||||||
on:
|
on:
|
||||||
# push:
|
# push:
|
||||||
# tags:
|
# tags:
|
||||||
# - 'v[0-9]+.[0-9]+.[0-9]+'
|
# - 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
# tags-ignore:
|
# tags-ignore:
|
||||||
# - '2.*'
|
# - '2.*'
|
||||||
# Allow run workflow manually from Action tab
|
# Allow run workflow manually from Action tab
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
IMAGE_VER:
|
IMAGE_VER:
|
||||||
description: "version for build image"
|
description: "version for build image"
|
||||||
type: string
|
type: string
|
||||||
env:
|
env:
|
||||||
REGISTRY: docker.frappet.com
|
REGISTRY: docker.frappet.com
|
||||||
IMAGE_NAME: demo/qualifying-exam-cms
|
IMAGE_NAME: demo/qualifying-exam-cms
|
||||||
DEPLOY_HOST: 49.0.91.80
|
DEPLOY_HOST: 49.0.91.80
|
||||||
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-qualifying-cms
|
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-qualifying-cms
|
||||||
jobs:
|
jobs:
|
||||||
# act workflow_dispatch --reuse -W .github/workflows/release.yaml --input IMAGE_VER=v0.2.4-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
|
# act workflow_dispatch --reuse -W .github/workflows/release.yaml --input IMAGE_VER=v0.2.4-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
|
||||||
# act --reuse --workflows .github/workflows/release.yaml --job release --input IMAGE_VER=v0.2.4-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
|
# act --reuse --workflows .github/workflows/release.yaml --job release --input IMAGE_VER=v0.2.4-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
|
||||||
|
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# https://thekevinwang.com/2022/06/13/github-actions-survival-skills/
|
# https://thekevinwang.com/2022/06/13/github-actions-survival-skills/
|
||||||
- name: Check out code # checkout only cms is possible but I checkout all
|
- name: Check out code # checkout only cms is possible but I checkout all
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Gen Version
|
- name: Gen Version
|
||||||
id: gen_ver
|
id: gen_ver
|
||||||
run: |
|
run: |
|
||||||
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
|
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
|
||||||
IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
|
IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
|
||||||
else
|
else
|
||||||
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
|
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
|
||||||
fi
|
fi
|
||||||
if [[ $IMAGE_VER == '' ]]; then
|
if [[ $IMAGE_VER == '' ]]; then
|
||||||
IMAGE_VER='beta'
|
IMAGE_VER='beta'
|
||||||
fi
|
fi
|
||||||
echo "{\"version\":\"$IMAGE_VER\", \"builddate\":\"$(date +"%Y-%m-%d_%T")\",\"ref_name\":\"$GITHUB_REF\" }" > ./cms/src/lib/ver.json
|
echo "{\"version\":\"$IMAGE_VER\", \"builddate\":\"$(date +"%Y-%m-%d_%T")\",\"ref_name\":\"$GITHUB_REF\" }" > ./cms/src/lib/ver.json
|
||||||
cat ./cms/src/lib/ver.json
|
cat ./cms/src/lib/ver.json
|
||||||
echo '::set-output name=image_ver::'$IMAGE_VER
|
echo '::set-output name=image_ver::'$IMAGE_VER
|
||||||
# - name: Debug act
|
# - name: Debug act
|
||||||
# if: ${{ env.ACT }}
|
# if: ${{ env.ACT }}
|
||||||
# run: |
|
# run: |
|
||||||
# echo $GITHUB_REF
|
# echo $GITHUB_REF
|
||||||
# echo ${{ steps.gen_ver.outputs.image_ver }}
|
# echo ${{ steps.gen_ver.outputs.image_ver }}
|
||||||
# cat ./cms/src/lib/ver.json
|
# cat ./cms/src/lib/ver.json
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
- name: Login in to registry
|
- name: Login in to registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ${{env.REGISTRY}}
|
registry: ${{env.REGISTRY}}
|
||||||
username: ${{secrets.DOCKER_USER}}
|
username: ${{secrets.DOCKER_USER}}
|
||||||
password: ${{secrets.DOCKER_PASS}}
|
password: ${{secrets.DOCKER_PASS}}
|
||||||
- name: CMS Build and push docker image
|
- name: CMS Build and push docker image
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
context: cms
|
context: cms
|
||||||
cache-from: type=gha
|
file: docker/Dockerfile
|
||||||
cache-to: type=gha,mode=max
|
cache-from: type=gha
|
||||||
platforms: linux/amd64
|
cache-to: type=gha,mode=max
|
||||||
push: true
|
platforms: linux/amd64
|
||||||
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
|
push: true
|
||||||
- name: Remote Deployment
|
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
|
||||||
uses: appleboy/ssh-action@v0.1.8
|
- name: Remote Deployment
|
||||||
with:
|
uses: appleboy/ssh-action@v0.1.8
|
||||||
host: ${{env.DEPLOY_HOST}}
|
with:
|
||||||
username: frappet
|
host: ${{env.DEPLOY_HOST}}
|
||||||
password: ${{ secrets.SSH_PASSWORD }}
|
username: frappet
|
||||||
port: 10102
|
password: ${{ secrets.SSH_PASSWORD }}
|
||||||
script: |
|
port: 10102
|
||||||
cd "${{env.COMPOSE_PATH}}"
|
script: |
|
||||||
docker compose pull
|
cd "${{env.COMPOSE_PATH}}"
|
||||||
docker compose up -d
|
docker compose pull
|
||||||
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
docker compose up -d
|
||||||
|
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# docker build . -t docker.frappet.com/demo/qualifying-exam-cms:latest
|
# docker build . -t docker.frappet.com/demo/qualifying-exam-cms:latest
|
||||||
FROM node:18 as build
|
FROM node:latest as build-stage
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
# optimize build speed by copy all .xx folder and
|
# optimize build speed by copy all .xx folder and
|
||||||
COPY *.json .
|
COPY *.json .
|
||||||
|
|
@ -9,7 +9,7 @@ COPY static ./static
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
# RUN ls
|
# RUN ls
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
FROM node:18-alpine
|
FROM node:lts-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app .
|
COPY --from=build /app .
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
Loading…
Add table
Add a link
Reference in a new issue