From 1665f328abd267d18b36fab555dc4422a0e29600 Mon Sep 17 00:00:00 2001 From: Yusron alamsyah Date: Mon, 13 Apr 2026 09:22:42 +0700 Subject: [PATCH] add dockerfile --- .gitignore | 4 +--- Dockerfile | 35 +++++++++++++++++++++++++++++++++++ docker-compose.yml | 19 +++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 97e75a5..ef319dd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,4 @@ node_modules .cache .output .env -dist -Dockerfile -docker-compose.yml \ No newline at end of file +dist \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..417075a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# syntax=docker/dockerfile:1 + +FROM node:20-alpine AS deps +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm ci + + +FROM node:20-alpine AS build +WORKDIR /app + +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +RUN npm run build + + +FROM node:20-alpine AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV NITRO_HOST=0.0.0.0 +ENV NITRO_PORT=3001 +ENV HOST=0.0.0.0 +ENV PORT=3001 +ENV AUTH_ORIGIN=http://localhost:3001 + +COPY --from=build /app/.output ./.output + +RUN chown -R node:node /app +USER node + +EXPOSE 3001 +CMD ["node", ".output/server/index.mjs"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..01c2118 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +version: '3.8' + +services: + app: + build: + context: . + dockerfile: Dockerfile + container_name: module-farmasi + env_file: + - .env + environment: + AUTH_ORIGIN: ${AUTH_ORIGIN:-http://localhost:3001} + NITRO_HOST: ${NITRO_HOST:-0.0.0.0} + NITRO_PORT: ${NITRO_PORT:-3001} + HOST: ${HOST:-0.0.0.0} + PORT: ${PORT:-3001} + ports: + - "3001:3001" + restart: unless-stopped