Skip to content

Commit e81995e

Browse files
committed
feat: ad dockerfile & ci for cd
1 parent 307e8bd commit e81995e

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

.github/workflows/docker_cd.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
env:
10+
DEPLOY_NAME: 'vidar-website'
11+
IMAGE_REPO: 'vidar-team/vidar-website'
12+
IMAGE_BASE: 'registry.cn-hangzhou.aliyuncs.com'
13+
14+
jobs:
15+
build:
16+
if: github.repository == 'vidar-team/Vidar-Website'
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Gen tag
24+
id: gen-tag
25+
run: |
26+
echo "tag=$(date +%s)" >> $GITHUB_OUTPUT
27+
echo "Generated tag: ${{ steps.gen-tag.outputs.tag }}"
28+
29+
- name: Build the Docker image
30+
run: |
31+
echo "Building Website image with tag: ${{ steps.gen-tag.outputs.tag }}"
32+
docker build --no-cache -f Dockerfile ./blog --tag ${{ env.IMAGE_BASE }}/${{ env.IMAGE_REPO }}-main:${{ steps.gen-tag.outputs.tag }}
33+
- name: Push the Docker image
34+
timeout-minutes: 3
35+
run: |
36+
echo "Logging into Docker registry: ${{ env.IMAGE_BASE }}"
37+
docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }} ${{ env.IMAGE_BASE }}
38+
39+
echo "Pushing Website Docker image with tag: ${{ steps.gen-tag.outputs.tag }}"
40+
docker push ${{ env.IMAGE_BASE }}/${{ env.IMAGE_REPO }}-main:${{ steps.gen-tag.outputs.tag }}
41+
42+
- name: Checkout ArgoCD
43+
uses: actions/checkout@v4
44+
with:
45+
repository: vidar-team-devops/argocd
46+
ssh-key: ${{ secrets.ARGO_KEY_SSH }}
47+
path: deploy
48+
49+
# - name: Update ArgoCD
50+
# run: |
51+
# cd deploy/tutu
52+
# git config user.name github-actions
53+
# git config user.email [email protected]
54+
# sed -i "s|^\(\s*image:\s*.*:\)[0-9]\+|\1${{ steps.gen-tag.outputs.tag }}|" ./tutu/tutu-deployment.yml
55+
# sed -i "s|^\(\s*image:\s*.*:\)[0-9]\+|\1${{ steps.gen-tag.outputs.tag }}|" ./rsa-web-api/rsa-web-api-deployment.yml
56+
# sed -i "s|^\(\s*image:\s*.*:\)[0-9]\+|\1${{ steps.gen-tag.outputs.tag }}|" ./blog-mysql/blog-mysql-deployment.yml
57+
# git add .
58+
# git commit -m "update: image"
59+
# git push
60+

Dockerfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM node:22-bookworm AS dep-builder
2+
3+
WORKDIR /app
4+
5+
# place ARG statement before RUN statement which need it to avoid cache miss
6+
ARG USE_CHINA_NPM_REGISTRY=1
7+
RUN \
8+
set -ex && \
9+
if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then \
10+
echo 'use npm mirror' && \
11+
npm config set registry https://registry.npmmirror.com && \
12+
yarn config set registry https://registry.npmmirror.com; \
13+
fi;
14+
15+
COPY ./yarn.lock /app/
16+
COPY ./package.json /app/
17+
COPY ./poi.config.js /app/
18+
COPY ./public /app/public
19+
COPY ./src /app/src
20+
21+
RUN \
22+
set -ex && \
23+
ls && \
24+
yarn
25+
26+
Run \
27+
set -ex && \
28+
cd /app/ && \
29+
yarn build

tmp/test

-1
This file was deleted.

0 commit comments

Comments
 (0)