set file deploy
This commit is contained in:
parent
5640c9bd68
commit
4be268d562
6 changed files with 156 additions and 1 deletions
1
.env.production
Normal file
1
.env.production
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
VITE_API_URI_CONFIG=VITE_API_URI_CONFIG
|
||||||
86
.github/workflows/release.yaml
vendored
Normal file
86
.github/workflows/release.yaml
vendored
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
name: release-dev
|
||||||
|
run-name: release-dev ${{ github.actor }}
|
||||||
|
on:
|
||||||
|
# push:
|
||||||
|
# tags:
|
||||||
|
# - 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
# tags-ignore:
|
||||||
|
# - '2.*'
|
||||||
|
# Allow run workflow manually from Action tab
|
||||||
|
workflow_dispatch:
|
||||||
|
env:
|
||||||
|
REGISTRY: docker.frappet.com
|
||||||
|
IMAGE_NAME: ehr/bma-ehr-user
|
||||||
|
DEPLOY_HOST: frappet.com
|
||||||
|
COMPOSE_PATH: /home/frappet/docker/bma-ehr-user
|
||||||
|
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=test-v6.1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
|
||||||
|
release-dev:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
# skip Set up QEMU because it fail on act and container
|
||||||
|
- name: Gen Version
|
||||||
|
id: gen_ver
|
||||||
|
run: |
|
||||||
|
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
|
||||||
|
IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
|
||||||
|
else
|
||||||
|
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
|
||||||
|
fi
|
||||||
|
if [[ $IMAGE_VER == '' ]]; then
|
||||||
|
IMAGE_VER='test-vBeta'
|
||||||
|
fi
|
||||||
|
echo '::set-output name=image_ver::'$IMAGE_VER
|
||||||
|
- name: Test Version
|
||||||
|
run: |
|
||||||
|
echo $GITHUB_REF
|
||||||
|
echo ${{ steps.gen_ver.outputs.image_ver }}
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login in to registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ${{env.REGISTRY}}
|
||||||
|
username: ${{secrets.DOCKER_USER}}
|
||||||
|
password: ${{secrets.DOCKER_PASS}}
|
||||||
|
- name: Build and load local docker image
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
|
||||||
|
|
||||||
|
- name: Reload docker compose
|
||||||
|
uses: appleboy/ssh-action@v0.1.8
|
||||||
|
with:
|
||||||
|
host: ${{env.DEPLOY_HOST}}
|
||||||
|
username: frappet
|
||||||
|
password: ${{ secrets.SSH_PASSWORD }}
|
||||||
|
port: 22
|
||||||
|
script: |
|
||||||
|
cd "${{env.COMPOSE_PATH}}"
|
||||||
|
docker-compose pull
|
||||||
|
docker-compose up -d
|
||||||
|
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
||||||
|
# - uses: snow-actions/line-notify@v1.1.0
|
||||||
|
# if: success()
|
||||||
|
# with:
|
||||||
|
# access_token: ${{ env.TOKEN_LINE }}
|
||||||
|
# message: |
|
||||||
|
# -Success✅✅✅
|
||||||
|
# Image: ${{env.IMAGE_NAME}}
|
||||||
|
# Version: ${{ github.event.inputs.IMAGE_VER }}
|
||||||
|
# By: ${{secrets.DOCKER_USER}}
|
||||||
|
# - uses: snow-actions/line-notify@v1.1.0
|
||||||
|
# if: failure()
|
||||||
|
# with:
|
||||||
|
# access_token: ${{ env.TOKEN_LINE }}
|
||||||
|
# message: |
|
||||||
|
# -Failure❌❌❌
|
||||||
|
# Image: ${{env.IMAGE_NAME}}
|
||||||
|
# Version: ${{ github.event.inputs.IMAGE_VER }}
|
||||||
|
# By: ${{secrets.DOCKER_USER}}
|
||||||
21
Dockerfile
Normal file
21
Dockerfile
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
# docker build . -t docker.frappet.com/demo/fe:latest
|
||||||
|
FROM node:latest as build-stage
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
COPY ./ .
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM nginx as production-stage
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
COPY --from=build-stage /app/dist /app
|
||||||
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
RUN chmod u+x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
16
entrypoint.sh
Normal file
16
entrypoint.sh
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
ROOT_DIR=/app
|
||||||
|
|
||||||
|
# Replace env vars in JavaScript files
|
||||||
|
echo "Replacing env constants in JS"
|
||||||
|
for file in $ROOT_DIR/assets/app.*.js* $ROOT_DIR/js/app.*.js* $ROOT_DIR/index.html $ROOT_DIR/precache-manifest*.js;
|
||||||
|
do
|
||||||
|
echo "Processing $file ...";
|
||||||
|
|
||||||
|
sed -i 's|VITE_API_URI_CONFIG|'${VITE_API_URI_CONFIG}'|g' $file
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Starting Nginx"
|
||||||
|
nginx -g 'daemon off;'
|
||||||
30
nginx.conf
Normal file
30
nginx.conf
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
user nginx;
|
||||||
|
worker_processes 1;
|
||||||
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
access_log /var/log/nginx/access.log main;
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
location / {
|
||||||
|
root /app;
|
||||||
|
index index.html;
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import { ref } from "vue"
|
import { ref } from "vue"
|
||||||
|
|
||||||
const env = ref<string>(process.env.NODE_ENV || "development")
|
const env = ref<string>(process.env.NODE_ENV || "development")
|
||||||
|
export const apiUrlConfig = import.meta.env.VITE_API_URI_CONFIG
|
||||||
// if (process.env.VUE_APP_TEST) {
|
// if (process.env.VUE_APP_TEST) {
|
||||||
// env = "test";
|
// env = "test";
|
||||||
// }
|
// }
|
||||||
|
|
@ -17,7 +18,7 @@ const config = ref<any>({
|
||||||
MEET_URI: "meet.frappet.com",
|
MEET_URI: "meet.frappet.com",
|
||||||
},
|
},
|
||||||
production: {
|
production: {
|
||||||
API_URI: `${window.location.protocol}//${window.location.host}/api/v1`,
|
API_URI: apiUrlConfig,
|
||||||
API_URI_ORG_TREE: "https://s3cluster.frappet.com/bma-ehr-fpt/organization/strueture/tree_20230707_115124.json",
|
API_URI_ORG_TREE: "https://s3cluster.frappet.com/bma-ehr-fpt/organization/strueture/tree_20230707_115124.json",
|
||||||
MEET_URI: "meet.frappet.com",
|
MEET_URI: "meet.frappet.com",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue