Skip to content

Commit

Permalink
feat: dockerize this project
Browse files Browse the repository at this point in the history
  • Loading branch information
mzrtamp committed Mar 7, 2024
1 parent 0732915 commit 15cfad7
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build & Push Docker Image to container image registry

on:
release:
types: [created]
push:
branches:
- main
pull_request:
branches:
- main
paths:
- "Dockerfile"

jobs:
docker:
uses: stegripe/workflows/.github/workflows/docker-build.yml@main
secrets: inherit
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ghcr.io/hazmi35/node:21-dev-alpine as build-stage

# Prepare pnpm with corepack (experimental feature)
RUN corepack enable && corepack prepare pnpm@latest

# Copy package.json, lockfile and npm config files
COPY package.json pnpm-lock.yaml *.npmrc ./

# Fetch dependencies to virtual store
RUN pnpm fetch

# Install dependencies
RUN pnpm install --offline --frozen-lockfile

# Copy Project files
COPY . .

# Build TypeScript Project
RUN pnpm run build

# Prune devDependencies
RUN pnpm prune --production

# Get ready for production
FROM ghcr.io/hazmi35/node:21-alpine

LABEL name "linkbio"
LABEL maintainer "Stegripe <[email protected]>"

# Copy needed files
COPY --from=build-stage /tmp/build/package.json .
COPY --from=build-stage /tmp/build/.next/ ./.next
COPY --from=build-stage /tmp/build/node_modules ./node_modules
COPY --from=build-stage /tmp/build/next.config.js ./

# Additional Environment Variables
ENV NODE_ENV production

# Expose the port the app runs on
EXPOSE 3000

# Start the app with node
CMD ["npm", "run", "start"]

0 comments on commit 15cfad7

Please sign in to comment.