Skip to content

Commit 8a2ab79

Browse files
authored
fix(deployment): remade Dockerfile with correct copies, ignore file and workflows (#167) #major
1 parent 637166a commit 8a2ab79

File tree

8 files changed

+148
-151
lines changed

8 files changed

+148
-151
lines changed

.dockerignore

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
# Nuxt dev outputs
2+
.data
3+
.nuxt
4+
.nitro
5+
.cache
6+
dist
7+
8+
# Node dependencies
19
node_modules
210

3-
.next
4-
.cache
11+
# Logs
12+
logs
13+
*.log
14+
15+
# Misc
16+
.DS_Store
17+
.fleet
18+
.idea
19+
.vscode
520

6-
npm-debug.log
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example

.env.example

Whitespace-only changes.

.github/workflows/assign.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
name: Automatically assign User that opened issue or pull requested from repository
1+
name: Automatically assign user that opened the issue or pull requested from repository
22
on:
33
issues:
4-
types: [opened]
4+
types:
5+
- opened
6+
pull_request:
7+
types:
8+
- opened
9+
- reopened
10+
branches:
11+
- main
12+
513
jobs:
6-
run:
14+
assign:
15+
name: Assign user
716
runs-on: ubuntu-latest
817
permissions:
918
issues: write
1019
pull-requests: write
1120
steps:
12-
- name: Assign issue for User
13-
uses: pozil/auto-assign-issue@v1
14-
with:
21+
- name: Assign an issue for user
22+
uses: pozil/auto-assign-issue@v2
23+
with:
1524
repo-token: ${{ secrets.GITHUB_TOKEN }}
1625
assignees: ${{ github.actor }}
1726
numOfAssignee: 1

.github/workflows/ci.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Build and publish Docker image
2+
3+
on:
4+
push:
5+
branches: [test/workflow]
6+
workflow_dispatch:
7+
pull_request:
8+
types: [closed]
9+
branches: [main]
10+
11+
concurrency: production
12+
13+
jobs:
14+
release:
15+
name: Tag and create GitHub release
16+
if: github.event.pull_request.merged == true
17+
runs-on: ubuntu-24.04-arm
18+
permissions:
19+
contents: write
20+
outputs:
21+
new_tag: ${{ steps.version.outputs.new_tag }}
22+
part: ${{ steps.version.outputs.part }}
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Bump release version and push tag
28+
id: version
29+
uses: anothrNick/github-tag-action@1.71.0
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
GIT_API_TAGGING: true
33+
WITH_V: false
34+
INITIAL_VERSION: 1.0.0
35+
DEFAULT_BUMP: patch
36+
DEFAULT_BRANCH: main
37+
RELEASE_BRANCHES: main
38+
39+
- name: Create a GitHub release
40+
uses: ncipollo/release-action@v1
41+
with:
42+
tag: ${{ steps.version.outputs.new_tag }}
43+
name: Release ${{ steps.version.outputs.new_tag }}
44+
body: ${{ steps.version.outputs.changelog }}
45+
46+
publish:
47+
name: Build and publish Docker image to GitHub Packages
48+
needs: release
49+
if: needs.release.outputs.part != 'patch'
50+
runs-on: ubuntu-24.04-arm
51+
permissions:
52+
packages: write
53+
contents: read
54+
steps:
55+
- name: Checkout repository
56+
uses: actions/checkout@v4
57+
58+
- name: Authenticate with GitHub Container Registry
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ghcr.io
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Add tags and labels
66+
id: meta
67+
uses: docker/metadata-action@v5
68+
with:
69+
images: ghcr.io/${{ github.repository }}
70+
tags: type=semver,pattern={{version}},value=${{ needs.release.outputs.new_tag }}
71+
flavor: latest=auto
72+
73+
- name: Set up QEMU
74+
uses: docker/setup-qemu-action@v3
75+
with:
76+
platforms: arm64
77+
78+
- name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
with:
81+
platforms: linux/arm64
82+
83+
- name: Build and push Docker image
84+
uses: docker/build-push-action@v6
85+
with:
86+
context: .
87+
file: ./Dockerfile
88+
platforms: linux/arm64
89+
push: true
90+
tags: |
91+
ghcr.io/${{ github.repository }}:${{ needs.release.outputs.new_tag }}
92+
ghcr.io/${{ github.repository }}:latest
93+
labels: ${{ steps.meta.outputs.labels }}
94+
cache-from: type=gha
95+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
# Build a production distribution
22

3-
FROM cgr.dev/chainguard/node:latest AS setup
4-
5-
ARG SMTP_HOST
6-
ARG SMTP_USER
7-
ARG SMTP_PASSWORD
8-
9-
ENV SMTP_HOST=${SMTP_HOST}
10-
ENV SMTP_USER=${SMTP_USER}
11-
ENV SMTP_PASSWORD=${SMTP_PASSWORD}
3+
FROM cgr.dev/chainguard/node:latest AS builder
124

135
WORKDIR /app
146

7+
ENV NEXT_TELEMETRY_DISABLED=1
8+
159
COPY --chown=node:node package*.json .
1610

1711
RUN npm install --clean
@@ -22,39 +16,28 @@ COPY --chown=node:node . .
2216

2317
RUN npm run build
2418

25-
# Setup production dependecies
19+
# Run output in a clean environment
2620

27-
FROM setup AS production
21+
FROM alpine AS runner
2822

2923
WORKDIR /app
3024

31-
COPY --chown=node:node package*.json .
32-
33-
ENV NODE_ENV=production
34-
35-
RUN npm install --clean --omit=dev
36-
37-
COPY --from=setup --chown=node:node /app/.next ./.next
25+
ENV NODE_ENV="production"
26+
ENV HOSTNAME="0.0.0.0"
27+
ENV PORT=3000
3828

39-
RUN npm prune --omit=dev
40-
41-
# Create a clean environment
42-
43-
FROM alpine AS runner
44-
45-
ENV NODE_ENV=production
46-
47-
LABEL authors = "botprzemek,pawelos231,akolt19d,nozowymrozon"
29+
LABEL authors="botprzemek,pawelos231,akolt19d,nozowymrozon"
4830

4931
RUN apk add --update nodejs
5032

51-
WORKDIR /app
52-
53-
COPY --from=production --chown=node:node /app/.next/standalone ./standalone
54-
COPY --from=production --chown=node:node /app/.next/static ./standalone/static
33+
RUN addgroup --system --gid 1001 nodejs
34+
RUN adduser --system --uid 1001 nextjs
5535

56-
COPY --from=setup --chown=node:node /app/public ./standalone/public
36+
COPY --from=builder /app/public ./public
37+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
38+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
5739

58-
CMD ["node", "./standalone/server.js"]
40+
USER nextjs
5941

6042
EXPOSE 3000
43+
CMD ["node", "server.js"]

next.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3-
output: 'standalone',
3+
output: "standalone",
44
};
55

66
export default nextConfig;

0 commit comments

Comments
 (0)