test
This commit is contained in:
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# .dockerignore
|
||||||
|
# node_modules
|
||||||
|
# npm-debug.log
|
||||||
|
# README.md
|
||||||
|
# .env*
|
||||||
|
# .next
|
||||||
|
# .git
|
||||||
95
.github/workflows/docker-build-push.yml
vendored
95
.github/workflows/docker-build-push.yml
vendored
@@ -1,69 +1,64 @@
|
|||||||
name: Build and Push Docker Image
|
name: Build and Push Docker Image to GHCR
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- main
|
||||||
workflow_dispatch:
|
tags:
|
||||||
inputs:
|
- 'v*.*.*'
|
||||||
version:
|
pull_request:
|
||||||
description: '镜像版本号'
|
branches:
|
||||||
required: false
|
- main
|
||||||
default: 'latest'
|
|
||||||
environment:
|
env:
|
||||||
description: '部署环境'
|
REGISTRY: ghcr.io
|
||||||
required: false
|
IMAGE_NAME: ${{ github.repository }}/wrdo
|
||||||
default: 'production'
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- production
|
|
||||||
- staging
|
|
||||||
- development
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
# 检出代码
|
||||||
uses: actions/checkout@v3
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
# 设置 QEMU 以支持多平台构建
|
|
||||||
- name: Set up QEMU
|
# 设置 Docker Buildx(支持多平台构建)
|
||||||
uses: docker/setup-qemu-action@v2
|
|
||||||
|
|
||||||
# 设置 Docker Buildx
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
# 登录到 GitHub Container Registry
|
||||||
|
- name: Log in to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
driver-opts: |
|
registry: ${{ env.REGISTRY }}
|
||||||
image=moby/buildkit:master
|
username: ${{ github.actor }}
|
||||||
network=host
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Login to DockerHub
|
# 提取 Docker 镜像元数据(标签、版本等)
|
||||||
uses: docker/login-action@v2
|
- name: Extract Docker metadata
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata
|
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: oiovwr/wrdo
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=${{ github.event.inputs.version || 'latest' }}
|
type=sha,format=short
|
||||||
type=raw,value=latest
|
type=ref,event=branch,prefix=
|
||||||
|
type=ref,event=tag
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v4
|
# 构建并推送 Docker 镜像
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
push: ${{ github.event_name != 'pull_request' }} # 仅在 push 时推送
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha,scope=${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cache-to: type=gha,mode=max,scope=${{ github.workflow }}-${{ github.ref }}
|
|
||||||
build-args: |
|
build-args: |
|
||||||
ENVIRONMENT=${{ github.event.inputs.environment || 'production' }}
|
ENVIRONMENT=${{ github.event.inputs.environment || 'production' }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
20
Dockerfile
20
Dockerfile
@@ -1,4 +1,4 @@
|
|||||||
FROM node:22-alpine AS base
|
FROM node:20-alpine AS base
|
||||||
|
|
||||||
FROM base AS deps
|
FROM base AS deps
|
||||||
RUN apk add --no-cache libc6-compat
|
RUN apk add --no-cache libc6-compat
|
||||||
@@ -19,21 +19,9 @@ WORKDIR /app
|
|||||||
|
|
||||||
RUN npm install -g pnpm
|
RUN npm install -g pnpm
|
||||||
|
|
||||||
# ARG NEXT_PUBLIC_APP_URL="http://localhost:3000"
|
ARG NEXT_PUBLIC_APP_URL="http://localhost:3000"
|
||||||
# ARG RESEND_API_KEY="re_"
|
ARG RESEND_API_KEY=""
|
||||||
# ARG DATABASE_URL=""
|
ARG DATABASE_URL=""
|
||||||
# ARG NEXT_PUBLIC_OPEN_SIGNUP="1"
|
|
||||||
# ARG GITHUB_TOKEN=""
|
|
||||||
# ARG AUTH_SECRET=""
|
|
||||||
# ARG GOOGLE_CLIENT_ID=""
|
|
||||||
# ARG GOOGLE_CLIENT_SECRET=""
|
|
||||||
# ARG GITHUB_ID=""
|
|
||||||
# ARG GITHUB_SECRET=""
|
|
||||||
# ARG LinuxDo_CLIENT_ID=""
|
|
||||||
# ARG LinuxDo_CLIENT_SECRET=""
|
|
||||||
# ARG NEXT_PUBLIC_EMAIL_R2_DOMAIN=""
|
|
||||||
# ARG NEXT_PUBLIC_GOOGLE_ID=""
|
|
||||||
# ARG SCREENSHOTONE_BASE_URL=""
|
|
||||||
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
version: "3.8"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build:
|
# build:
|
||||||
context: .
|
# context: .
|
||||||
dockerfile: Dockerfile
|
# dockerfile: Dockerfile
|
||||||
args:
|
# args:
|
||||||
RESEND_API_KEY: ${RESEND_API_KEY}
|
# RESEND_API_KEY: ${RESEND_API_KEY}
|
||||||
# image: ghcr.io/oiov/wr.do/wrdo:${TAG:-latest}
|
image: ghcr.io/oiov/wr.do/wrdo:${TAG:-latest}
|
||||||
container_name: wrdo
|
container_name: wrdo
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
@@ -36,7 +34,6 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- wrdo-network
|
- wrdo-network
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
# command: ["bash", "-c", "pnpm db:push && node server.js"]
|
|
||||||
|
|
||||||
# If you want to use local database, uncomment the following line
|
# If you want to use local database, uncomment the following line
|
||||||
# postgres:
|
# postgres:
|
||||||
|
|||||||
Reference in New Issue
Block a user