Skip to content

Commit dd70ed3

Browse files
committed
Add docker compose setup
Add docker compose setup to facilitate the deployment in railway.
1 parent da368c7 commit dd70ed3

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

.dockerignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
node_modules
2+
.git
3+
.github
4+
.vscode
5+
.kiro
6+
*.md
7+
.env
8+
.env.local
9+
.env.*.local
10+
.nuxt
11+
.output
12+
dist
13+
coverage
14+
.nyc_output
15+
*.log
16+
npm-debug.log*
17+
yarn-debug.log*
18+
yarn-error.log*
19+
pnpm-debug.log*
20+
lerna-debug.log*

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Use Node.js 20 Alpine as base image
2+
FROM node:20-alpine AS base
3+
4+
# Install pnpm
5+
RUN npm install -g pnpm@10.17.1
6+
7+
# Set working directory
8+
WORKDIR /app
9+
10+
# Copy package files
11+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
12+
13+
# Install dependencies
14+
RUN pnpm install --frozen-lockfile
15+
16+
# Copy source code
17+
COPY . .
18+
19+
# Build stage
20+
FROM base AS build
21+
22+
# Build the application
23+
RUN pnpm build
24+
25+
# Production stage
26+
FROM node:20-alpine AS production
27+
28+
# Install pnpm
29+
RUN npm install -g pnpm@10.17.1
30+
31+
WORKDIR /app
32+
33+
# Copy package files
34+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
35+
36+
# Install only production dependencies
37+
RUN pnpm install --frozen-lockfile --prod
38+
39+
# Copy built application from build stage
40+
COPY --from=build /app/.output ./.output
41+
COPY --from=build /app/.nuxt ./.nuxt
42+
43+
# Expose port
44+
EXPOSE 3000
45+
46+
# Set environment
47+
ENV NODE_ENV=production
48+
ENV NITRO_HOST=0.0.0.0
49+
ENV NITRO_PORT=3000
50+
51+
# Start the application
52+
CMD ["node", ".output/server/index.mjs"]

docker-compose.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
include:
2+
- database/docker-compose.yml
3+
4+
services:
5+
# Nuxt.js Application
6+
app:
7+
container_name: pay-app
8+
build:
9+
context: .
10+
dockerfile: Dockerfile
11+
restart: unless-stopped
12+
ports:
13+
- '${APP_PORT:-3000}:3000'
14+
depends_on:
15+
db:
16+
condition: service_healthy
17+
kong:
18+
condition: service_started
19+
environment:
20+
# Database connection
21+
POSTGRES_HOST: db
22+
POSTGRES_PORT: 5432
23+
POSTGRES_USER: postgres
24+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
25+
POSTGRES_DB: ${POSTGRES_DB:-postgres}
26+
27+
# API configuration
28+
SUPABASE_PUBLIC_URL: http://kong:8000
29+
ANON_KEY: ${ANON_KEY}
30+
SERVICE_ROLE_KEY: ${SERVICE_ROLE_KEY}
31+
32+
# Google API
33+
NUXT_GOOGLE_API_KEY: ${NUXT_GOOGLE_API_KEY}
34+
35+
# Node environment
36+
NODE_ENV: production
37+
env_file:
38+
- .env
39+
volumes:
40+
# Mount source code for development (remove in production)
41+
- .:/app
42+
- /app/node_modules
43+
networks:
44+
- default
45+
46+
networks:
47+
default:
48+
driver: bri

0 commit comments

Comments
 (0)