From cb706b6462d3aba368686491dd8753904da708f0 Mon Sep 17 00:00:00 2001 From: smfahim25 Date: Thu, 20 Mar 2025 12:55:38 +0600 Subject: [PATCH] added docker --- Dockerfile | 37 ++++++++++++++++++++++++++++++++ docker-compose.yml | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2ebbd0b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# Build stage +FROM oven/bun:1 AS builder + +# Copy package files +COPY package.json . +COPY bun.lockb . + +# Install dependencies +RUN bun install --frozen-lockfile + +# Copy source code +COPY . . + +# Build the application +RUN bun run build + +EXPOSE 5005 + +# Production stage +# FROM debian:bookworm-slim + +# WORKDIR /app + +# # Copy only the compiled binary from builder +# COPY --from=builder /app/server . + +# # Expose the port your app runs on +# EXPOSE 3000 + +# # Copy the entrypoint script +# COPY entrypoint.sh . + +# Make the entrypoint script executable +RUN chmod +x ./entrypoint.sh + +# Set the entrypoint +ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b3e5f21 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,53 @@ +services: + api: + build: + context: . + dockerfile: Dockerfile + ports: + - "5005:5005" + depends_on: + db: + condition: service_healthy + minio: + condition: service_healthy + environment: + NODE_ENV: production + DATABASE_URL: ${DATABASE_URL} + + db: + image: postgres:latest + environment: + POSTGRES_USER: ${DB_USER} + POSTGRES_PASSWORD: ${DB_PASSWORD} + POSTGRES_DB: ${DB_NAME} + # ports: + # - "${DB_PORT}:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s + + minio: + image: minio/minio:latest + # ports: + # - "9000:9000" + # - "9001:9001" + environment: + MINIO_ROOT_USER: ${MINIO_ROOT_USER} + MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD} + command: server /data --console-address ":9001" + volumes: + - minio_data:/data + healthcheck: + test: ["CMD", "mc", "ready", "local"] + interval: 30s + timeout: 20s + retries: 3 + +volumes: + postgres_data: + minio_data: