Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
feat: add docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
ziteh committed Sep 15, 2024
1 parent 92e9c5d commit 3611ef0
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.pnpm
.next
.git
**/*.db
prisma/migrations/

!.next/static
!.next/standalone
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ next-env.d.ts
/prisma/migrations/
*.db
*.db-journal

# Docker
.docker_temp_*
*.tar
43 changes: 28 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
# Use Node.js 20 as the base image
FROM node:20
FROM node:20-alpine AS base

# Build stage
FROM base AS build

# Set the working directory inside the container
WORKDIR /app

# Copy package.json and pnpm-lock.yaml (or package-lock.json)
COPY package*.json ./
ENV DATABASE_URL=file:/app/db/hie_sqlite.db

# Install dependencies using pnpm
RUN npm install -g pnpm
RUN pnpm install
COPY package.json pnpm-lock.yaml* ./
RUN corepack enable pnpm && pnpm install --frozen-lockfile

# Copy the rest of the application code
COPY . .
RUN pnpm run prisma:update && pnpm run build

# Expose the port your Next.js app will run on
EXPOSE 3000
# Remove dev dependencies
RUN pnpm prune --prod

# Production stage
FROM base

WORKDIR /app

# Build the Next.js app
RUN pnpm run build
ENV NODE_ENV=production
ENV DATABASE_URL=file:/app/db/hie_sqlite.db

RUN npm install -g pnpm

COPY --from=build /app/db/hie_sqlite.db /app/db/hie_sqlite.db
COPY --from=build /app/.next /app/.next
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/package.json /app/package.json
COPY --from=build /app/public /app/public

EXPOSE 3000

# Start the app
CMD ["pnpm", "start"]
CMD ["pnpm", "run", "start"]
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3"
services:
app:
image: hie
build:
context: .
ports:
- "5888:3000"
volumes:
- HOST_DIR:/app/data
# restart: always
4 changes: 3 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
output: "standalone",
};

export default nextConfig;

0 comments on commit 3611ef0

Please sign in to comment.