Skip to content

Commit

Permalink
feat: 尝试配置cicd和Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Zecyel committed Oct 21, 2023
1 parent d1967b1 commit b05c8ba
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AUTH=https://auth.jingyijun.xyz:9443/api
TREEHOLE=https://hole.jingyijun.xyz:9443/api
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AUTH=https://auth.fduhole.com/api
TREEHOLE=https://www.fduhole.com/api
30 changes: 30 additions & 0 deletions .github/workflows/docker-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish to Docker - Development

on:
push:
branches: [dev]

env:
APP_NAME: admin-frontend

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@master
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@master
- name: Login to DockerHub
uses: docker/login-action@master
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@master
with:
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}:dev
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}:latest
30 changes: 30 additions & 0 deletions .github/workflows/docker-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish to Docker - Production

on:
push:
branches: [master]

env:
APP_NAME: auth-frontend-next

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@master
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@master
- name: Login to DockerHub
uses: docker/login-action@master
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@master
with:
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}:master
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
pnpm-lock.yaml
dist
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM node:18-alpine as builder

WORKDIR /app

RUN npm install -g pnpm

COPY package.json pnpm-lock.yaml /app/

RUN pnpm install --frozen-lockfile

COPY . /app

RUN pnpm build

FROM nginx:alpine

RUN rm /etc/nginx/conf.d/default.conf

ADD default.conf /etc/nginx/conf.d/

COPY --from=builder /app/dist /usr/share/nginx/html

COPY ./entryPoint.sh /
RUN chmod +x entryPoint.sh

EXPOSE 80

ENTRYPOINT ["sh","/entryPoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
17 changes: 17 additions & 0 deletions default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# nginx config file

server {
listen 80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
8 changes: 4 additions & 4 deletions src/util/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// export const AUTH = "https://auth.fduhole.com/api";
export const AUTH = "https://auth.jingyijun.xyz:9443/api";
export const AUTH = "https://auth.fduhole.com/api";
// export const AUTH = "https://auth.jingyijun.xyz:9443/api";

// export const TREEHOLE = "https://www.fduhole.com";
export const TREEHOLE = "https://hole.jingyijun.xyz:9443/api";
export const TREEHOLE = "https://www.fduhole.com/api";
// export const TREEHOLE = "https://hole.jingyijun.xyz:9443/api";

0 comments on commit b05c8ba

Please sign in to comment.