Skip to content

Commit 3fea2d3

Browse files
committed
test build
1 parent 4fc9f22 commit 3fea2d3

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
env:
12+
IMAGE_NAME: safetychecker
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v1
20+
21+
- name: Login to GitHub Container Registry
22+
uses: docker/login-action@v2
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.repository_owner }}
26+
password: ${{ secrets.GH_NPM_TOKEN }}
27+
28+
- name: Build and push
29+
uses: docker/build-push-action@v4
30+
with:
31+
secrets: |
32+
GH_NPM_TOKEN=${{ secrets.GH_NPM_TOKEN }}
33+
platforms: linux/amd64,linux/arm64
34+
context: .
35+
push: true
36+
tags: |
37+
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest
38+
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ github.sha }}

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# syntax = docker/dockerfile:1
2+
3+
# Adjust BUN_VERSION as desired
4+
ARG BUN_VERSION=1.1.20
5+
FROM oven/bun:${BUN_VERSION}-slim as base
6+
7+
# Next.js app lives here
8+
WORKDIR /app
9+
10+
# Set production environment
11+
ENV NODE_ENV="production"
12+
13+
# Throw-away build stage to reduce size of final image
14+
FROM base as build
15+
16+
# Install packages needed to build node modules
17+
RUN apt-get update -qq && \
18+
apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3
19+
20+
# Mount the GH_NPM_TOKEN secret and use it to create bunfig.toml
21+
RUN --mount=type=secret,id=GH_NPM_TOKEN \
22+
echo '[install.scopes]' > bunfig.toml && \
23+
echo 'neodyland = { token = "'$(cat /run/secrets/GH_NPM_TOKEN)'", url = "https://npm.pkg.github.com/" }' >> bunfig.toml
24+
25+
# Install node modules
26+
COPY --link bun.lockb package.json ./
27+
RUN bun install
28+
29+
# Copy application code
30+
COPY --link . .
31+
32+
# Build application
33+
RUN bun run build
34+
35+
# Remove development dependencies
36+
RUN rm -rf node_modules && \
37+
bun install --ci
38+
39+
# Remove bunfig.toml to avoid token leakage
40+
RUN rm -f bunfig.toml
41+
42+
# Final stage for app image
43+
FROM base
44+
45+
# Copy built application
46+
COPY --from=build /app/.next/standalone /app
47+
COPY --from=build /app/.next/static /app/.next/static
48+
COPY --from=build /app/public /app/public
49+
50+
# Start the server by default, this can be overwritten at runtime
51+
EXPOSE 3000
52+
CMD [ "bun", "server.js" ]

0 commit comments

Comments
 (0)