Skip to content

Commit

Permalink
feat: container and its CI
Browse files Browse the repository at this point in the history
  • Loading branch information
yamader committed Apr 14, 2024
1 parent bfa2f0f commit 6abf350
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: container

on:
push:
branches: [v3]
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: kcctdensan/densan-web

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM oven/bun:1 as base
FROM oven/bun:1-alpine as base

WORKDIR /usr/src/app

Expand All @@ -7,11 +7,11 @@ FROM base as deps

RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile
RUN cd /temp/dev && bun install --frozen-lockfile --ignore-scripts

RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production
RUN cd /temp/prod && bun install --frozen-lockfile --production --ignore-scripts

# Build the app
FROM base as build
Expand All @@ -20,10 +20,12 @@ COPY --from=deps /temp/dev/node_modules node_modules
COPY . .

ENV NODE_ENV=production
RUN bun run build
RUN bun run prepare && bun run build

################################################################

# Finally, build the production image with minimal footprint
FROM base AS release
FROM oven/bun:1-distroless AS release

WORKDIR /app

Expand All @@ -32,10 +34,9 @@ COPY --from=deps /temp/prod/node_modules node_modules
COPY --from=build /usr/src/app/build/ build/
COPY --from=build /usr/src/app/package.json .

USER bun
USER nonroot
EXPOSE 8080/tcp
ENV NODE_ENV=production
ENV PORT=8080

ENTRYPOINT ["bun", "start"]

ENTRYPOINT ["bun", "build/server/index.js"]
Binary file modified bun.lockb
Binary file not shown.

0 comments on commit 6abf350

Please sign in to comment.