Skip to content

Commit a5240da

Browse files
authored
Merge pull request #70 from teacoder-team/dev
chore: setup frontend containerization
2 parents b662d73 + 9798b03 commit a5240da

3 files changed

Lines changed: 75 additions & 81 deletions

File tree

.github/workflows/ci.yaml

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

.github/workflows/release.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
id-token: write
13+
14+
jobs:
15+
build-and-push:
16+
name: Build and Push
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Log in to Docker Hub
28+
uses: docker/login-action@v3
29+
with:
30+
username: ${{ secrets.DOCKERHUB_USERNAME }}
31+
password: ${{ secrets.DOCKERHUB_TOKEN }}
32+
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
file: ./Dockerfile
38+
push: true
39+
build-args: |
40+
NEXT_PUBLIC_APP_URL=${{ secrets.NEXT_PUBLIC_APP_URL }}
41+
NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}
42+
tags: |
43+
${{ secrets.DOCKERHUB_USERNAME }}/frontend:latest
44+
${{ secrets.DOCKERHUB_USERNAME }}/frontend:${{ github.sha }}
45+
cache-from: type=gha
46+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
1-
FROM oven/bun:1 AS base
1+
FROM oven/bun:1-alpine AS deps
22

3-
WORKDIR /usr/src/app
3+
WORKDIR /app
44

55
COPY package.json bun.lock ./
66
RUN bun install --frozen-lockfile
77

8-
FROM oven/bun:1 AS release
8+
FROM oven/bun:1-alpine AS builder
99

10-
WORKDIR /usr/src/app
10+
WORKDIR /app
1111

12-
COPY --from=base /usr/src/app/node_modules node_modules
12+
COPY --from=deps /app/node_modules ./node_modules
1313
COPY . .
1414

15-
RUN bun --bun run build
15+
ARG NEXT_PUBLIC_APP_URL
16+
ARG NEXT_PUBLIC_API_URL
17+
ENV NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL
18+
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
1619

17-
CMD bun --bun run start
20+
RUN bun run build
1821

19-
EXPOSE 14701
22+
FROM node:22-alpine AS runner
23+
24+
WORKDIR /app
25+
26+
ENV NODE_ENV=production
27+
ENV NEXT_TELEMETRY_DISABLED=1
28+
29+
RUN addgroup --system --gid 1001 nodejs
30+
RUN adduser --system --uid 1001 nextjs
31+
32+
COPY --from=builder /app/public ./public
33+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
34+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
35+
36+
USER nextjs
37+
38+
EXPOSE 14702
39+
40+
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)