mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-06 03:30:25 -05:00
👷 ci(github): Release docker
This commit is contained in:
parent
cbe5f0d509
commit
5af60aa4de
62
.github/workflows/release-docker.yml
vendored
Normal file
62
.github/workflows/release-docker.yml
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
name: Build and Publish Docker Image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
IMAGE_NAME:
|
||||
- ppanel-user-web
|
||||
- ppanel-admin-web
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Extract version from package.json
|
||||
id: version
|
||||
run: echo "VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
|
||||
|
||||
- name: Get short SHA
|
||||
id: sha
|
||||
run: echo "GIT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV
|
||||
|
||||
- name: Build and push Docker image for main release
|
||||
if: github.event_name == 'release'
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/${{ matrix.IMAGE_NAME }}/Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKER_USERNAME }}/${{ matrix.IMAGE_NAME }}:latest
|
||||
${{ secrets.DOCKER_USERNAME }}/${{ matrix.IMAGE_NAME }}:${{ env.VERSION }}
|
||||
|
||||
- name: Build and push Docker image for develop
|
||||
if: github.ref == 'refs/heads/develop'
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/${{ matrix.IMAGE_NAME }}/Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKER_USERNAME }}/${{ matrix.IMAGE_NAME }}:beta
|
||||
${{ secrets.DOCKER_USERNAME }}/${{ matrix.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.GIT_SHA }}-beta
|
||||
@ -5,8 +5,9 @@ FROM base AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
# Install dependencies based on the preferred package manager
|
||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
||||
# Omit --production flag for TypeScript devDependencies
|
||||
RUN \
|
||||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
||||
@ -16,10 +17,8 @@ RUN \
|
||||
else echo "Warning: Lockfile not found. It is recommended to commit lockfiles to version control." && yarn install; \
|
||||
fi
|
||||
|
||||
COPY . .
|
||||
|
||||
# Build Next.js based on the preferred package manager
|
||||
RUN npx turbo build --filter=ppanel-admin-web...
|
||||
RUN npx turbo telemetry disable
|
||||
RUN npx turbo build --filter=ppanel-admin-web
|
||||
|
||||
# Note: It is not necessary to add an intermediate step that does a full copy of `node_modules` here
|
||||
|
||||
|
||||
@ -5,8 +5,9 @@ FROM base AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
# Install dependencies based on the preferred package manager
|
||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
||||
# Omit --production flag for TypeScript devDependencies
|
||||
RUN \
|
||||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
||||
@ -16,10 +17,8 @@ RUN \
|
||||
else echo "Warning: Lockfile not found. It is recommended to commit lockfiles to version control." && yarn install; \
|
||||
fi
|
||||
|
||||
COPY . .
|
||||
|
||||
# Build Next.js based on the preferred package manager
|
||||
RUN npx turbo build --filter=ppanel-user-web...
|
||||
RUN npx turbo telemetry disable
|
||||
RUN npx turbo build --filter=ppanel-user-web
|
||||
|
||||
# Note: It is not necessary to add an intermediate step that does a full copy of `node_modules` here
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user