fix: DockerFile

This commit is contained in:
Suphonchai Phoonsawat 2024-07-05 20:27:54 +07:00
parent 59340500b7
commit 0a0e2c3ca1

View file

@ -1,88 +1,88 @@
name: release-dev name: release-dev
run-name: release-dev ${{ github.actor }} run-name: release-dev ${{ 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:
env: env:
REGISTRY: docker.frappet.com REGISTRY: docker.frappet.com
IMAGE_NAME: ehr/bma-ehr-insignia-service IMAGE_NAME: ehr/bma-ehr-insignia-service
DEPLOY_HOST: frappet.com DEPLOY_HOST: frappet.com
DEPLOY_PORT: 10102 DEPLOY_PORT: 10102
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-insignia COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-insignia
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0 TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs: jobs:
# act workflow_dispatch -W .github/workflows/release_insignia.yaml --input IMAGE_VER=insignia-1.0.0 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd # act workflow_dispatch -W .github/workflows/release_insignia.yaml --input IMAGE_VER=insignia-1.0.0 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
release-dev: release-dev:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
# skip Set up QEMU because it fail on act and container # skip Set up QEMU because it fail on act and container
- 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='test-vBeta' IMAGE_VER='test-vBeta'
fi fi
echo '::set-output name=image_ver::'$IMAGE_VER echo '::set-output name=image_ver::'$IMAGE_VER
- name: Test Version - name: Test Version
run: | run: |
echo $GITHUB_REF echo $GITHUB_REF
echo ${{ steps.gen_ver.outputs.image_ver }} echo ${{ steps.gen_ver.outputs.image_ver }}
- 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: Build and load local docker image - name: Build and load local docker image
uses: docker/build-push-action@v3 uses: docker/build-push-action@v3
with: with:
context: . context: .
platforms: linux/amd64 platforms: linux/amd64
file: BMA.EHR.Insignia.Service/Dockerfile file: BMA.EHR.Insignia/Dockerfile
push: true push: true
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- name: Reload docker compose - name: Reload docker compose
uses: appleboy/ssh-action@v0.1.8 uses: appleboy/ssh-action@v0.1.8
with: with:
host: ${{env.DEPLOY_HOST}} host: ${{env.DEPLOY_HOST}}
username: frappet username: frappet
password: ${{ secrets.SSH_PASSWORD }} password: ${{ secrets.SSH_PASSWORD }}
port: ${{env.DEPLOY_PORT}} port: ${{env.DEPLOY_PORT}}
script: | script: |
cd "${{env.COMPOSE_PATH}}" cd "${{env.COMPOSE_PATH}}"
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
- uses: snow-actions/line-notify@v1.1.0 - uses: snow-actions/line-notify@v1.1.0
if: success() if: success()
with: with:
access_token: ${{ env.TOKEN_LINE }} access_token: ${{ env.TOKEN_LINE }}
message: | message: |
-Success✅✅✅ -Success✅✅✅
Image: ${{env.IMAGE_NAME}} Image: ${{env.IMAGE_NAME}}
Version: ${{ github.event.inputs.IMAGE_VER }} Version: ${{ github.event.inputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}} By: ${{secrets.DOCKER_USER}}
- uses: snow-actions/line-notify@v1.1.0 - uses: snow-actions/line-notify@v1.1.0
if: failure() if: failure()
with: with:
access_token: ${{ env.TOKEN_LINE }} access_token: ${{ env.TOKEN_LINE }}
message: | message: |
-Failure❌❌❌ -Failure❌❌❌
Image: ${{env.IMAGE_NAME}} Image: ${{env.IMAGE_NAME}}
Version: ${{ github.event.inputs.IMAGE_VER }} Version: ${{ github.event.inputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}} By: ${{secrets.DOCKER_USER}}