This repository has been archived by the owner on May 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
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
1 parent
b50bfd3
commit cbe313b
Showing
4 changed files
with
141 additions
and
0 deletions.
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
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,86 @@ | ||
name: Build and push Docker image | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
changelog: | ||
name: Generate Changelog | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release_body: ${{ steps.git-cliff.outputs.content }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Generate a changelog | ||
uses: orhun/git-cliff-action@v2 | ||
id: git-cliff | ||
with: | ||
config: git-cliff/cliff.toml | ||
args: -vv --latest --strip 'footer' | ||
env: | ||
OUTPUT: CHANGES.md | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
body: ${{ steps.git-cliff.outputs.content }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
env: | ||
GITHUB_REPOSITORY: ${{ github.repository }} | ||
|
||
build-and-push: | ||
runs-on: ubuntu-latest | ||
needs: changelog | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Login to AliYun Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: registry.cn-guangzhou.aliyuncs.com | ||
username: ${{ secrets.ALI_USERNAME }} | ||
password: ${{ secrets.ALI_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository }} | ||
registry.cn-guangzhou.aliyuncs.com/hamster-home/homedash | ||
tags: | | ||
type=raw,value=latest | ||
type=ref,event=tag | ||
- name: Print environment variables | ||
run: | | ||
echo "${{env.GIT_COMMIT_LOG}}" | ||
echo "${{env.BUILD_TIME}}" | ||
echo "${{env.CURRENT_VERSION}}" | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
GIT_TAG=${{env.CURRENT_VERSION}} | ||
GIT_COMMIT_LOG=${{env.GIT_COMMIT_LOG}} | ||
BUILD_TIME=${{env.BUILD_TIME}} | ||
NEXT_PUBLIC_GO_API_BASE_URL=${{secrets.NEXT_PUBLIC_GO_API_BASE_URL}} | ||
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,48 @@ | ||
FROM node:18-alpine AS base | ||
|
||
FROM base AS deps | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | ||
RUN \ | ||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||
elif [ -f package-lock.json ]; then npm ci; \ | ||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
|
||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
RUN yarn build | ||
|
||
|
||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ARG NEXT_PUBLIC_GO_API_BASE_URL=default_value | ||
ENV NEXT_PUBLIC_GO_API_BASE_URL=$NEXT_PUBLIC_GO_API_BASE_URL | ||
|
||
ENV NODE_ENV production | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
|
||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
ENV HOSTNAME "0.0.0.0" | ||
|
||
CMD ["node", "server.js"] |
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