Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dockerize app #39

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
.env
**/node_modules/
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Base image
FROM node:23-alpine AS base

# Install SQLite
RUN apk add --no-cache sqlite

# Set working directory inside container
WORKDIR /app

# Create database folder and initialize SQLite
RUN mkdir -p /app/db
RUN sqlite3 /app/db/database.db "VACUUM;"

# Copy package files to install dependencies
COPY ./yarn.lock ./package.json ./

# Install dependencies with Yarn
RUN yarn install

# Copy Prisma schema for migrations
COPY ./prisma ./prisma/

# Set DATABASE_URL for Prisma
ENV DATABASE_URL=file:/app/db/database.db

# Run Prisma migration to initialize DB
RUN npx prisma migrate dev --name init

# Copy the rest of the app files
COPY ./ ./

# Final app image
FROM node:23-alpine

WORKDIR /app

# Copy app files from base image
COPY --from=base ./app ./

ENV DATABASE_URL=file:/app/db/database.db

# Run the app in development mode
CMD ["yarn", "dev"]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ npx prisma migrate dev --name init
yarn dev
```

Atau pake docker

```bash
# jalankan
docker compose up -d

# untuk mematikan
docker compose down
```

buka API Documentation
[http://localhost:3000/api-docs](http://localhost:3000/api-docs)

Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
app:
build: .
ports:
- '3000:3000'
restart: unless-stopped
environment:
JWT_SECRET: NAKANO_ITSUKI
volumes:
- sqlite_data:/app/db
volumes:
sqlite_data: