forked from iCyris/Vidar-Website
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
workflow_dispatch: | ||
|
||
env: | ||
DEPLOY_NAME: 'vidar-website' | ||
IMAGE_REPO: 'vidar-team/vidar-website' | ||
IMAGE_BASE: 'registry.cn-hangzhou.aliyuncs.com' | ||
|
||
jobs: | ||
build: | ||
if: github.repository == 'vidar-team/Vidar-Website' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Gen tag | ||
id: gen-tag | ||
run: | | ||
echo "tag=$(date +%s)" >> $GITHUB_OUTPUT | ||
echo "Generated tag: ${{ steps.gen-tag.outputs.tag }}" | ||
- name: Build the Docker image | ||
run: | | ||
echo "Building Website image with tag: ${{ steps.gen-tag.outputs.tag }}" | ||
docker build --no-cache -f Dockerfile ./blog --tag ${{ env.IMAGE_BASE }}/${{ env.IMAGE_REPO }}-main:${{ steps.gen-tag.outputs.tag }} | ||
- name: Push the Docker image | ||
timeout-minutes: 3 | ||
run: | | ||
echo "Logging into Docker registry: ${{ env.IMAGE_BASE }}" | ||
docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }} ${{ env.IMAGE_BASE }} | ||
echo "Pushing Website Docker image with tag: ${{ steps.gen-tag.outputs.tag }}" | ||
docker push ${{ env.IMAGE_BASE }}/${{ env.IMAGE_REPO }}-main:${{ steps.gen-tag.outputs.tag }} | ||
- name: Checkout ArgoCD | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: vidar-team-devops/argocd | ||
ssh-key: ${{ secrets.ARGO_KEY_SSH }} | ||
path: deploy | ||
|
||
# - name: Update ArgoCD | ||
# run: | | ||
# cd deploy/tutu | ||
# git config user.name github-actions | ||
# git config user.email [email protected] | ||
# sed -i "s|^\(\s*image:\s*.*:\)[0-9]\+|\1${{ steps.gen-tag.outputs.tag }}|" ./tutu/tutu-deployment.yml | ||
# sed -i "s|^\(\s*image:\s*.*:\)[0-9]\+|\1${{ steps.gen-tag.outputs.tag }}|" ./rsa-web-api/rsa-web-api-deployment.yml | ||
# sed -i "s|^\(\s*image:\s*.*:\)[0-9]\+|\1${{ steps.gen-tag.outputs.tag }}|" ./blog-mysql/blog-mysql-deployment.yml | ||
# git add . | ||
# git commit -m "update: image" | ||
# git push | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM node:22-bookworm AS dep-builder | ||
|
||
WORKDIR /app | ||
|
||
# place ARG statement before RUN statement which need it to avoid cache miss | ||
ARG USE_CHINA_NPM_REGISTRY=1 | ||
RUN \ | ||
set -ex && \ | ||
if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then \ | ||
echo 'use npm mirror' && \ | ||
npm config set registry https://registry.npmmirror.com && \ | ||
yarn config set registry https://registry.npmmirror.com; \ | ||
fi; | ||
|
||
COPY ./yarn.lock /app/ | ||
COPY ./package.json /app/ | ||
COPY ./poi.config.js /app/ | ||
COPY ./public /app/public | ||
COPY ./src /app/src | ||
|
||
RUN \ | ||
set -ex && \ | ||
ls && \ | ||
yarn | ||
|
||
Run \ | ||
set -ex && \ | ||
cd /app/ && \ | ||
yarn build |