forked from IMPHNEN/kamus-gen-z-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from savareyhano/feat/update-dockerfile
feat: Update Dockerfile
- Loading branch information
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +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"] |