Compare commits
4 commits
247e520900
...
b1e8b7a664
| Author | SHA1 | Date | |
|---|---|---|---|
| b1e8b7a664 | |||
|
|
53d2c7b46a | ||
|
|
b247985a93 | ||
|
|
0a2494cd7e |
6 changed files with 110 additions and 9 deletions
37
Dockerfile
Normal file
37
Dockerfile
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Build stage
|
||||||
|
FROM oven/bun:1 AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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"]
|
||||||
53
docker-compose.yml
Normal file
53
docker-compose.yml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
services:
|
||||||
|
api:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
# ports:
|
||||||
|
# - "${SERVER_PORT}:${SERVER_PORT}"
|
||||||
|
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:
|
||||||
9
entrypoint.sh
Normal file
9
entrypoint.sh
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Run migrations
|
||||||
|
bun run db:migrate
|
||||||
|
|
||||||
|
# Start the application
|
||||||
|
echo "Starting the application..."
|
||||||
|
./server
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
"db:generate": "drizzle-kit generate",
|
"db:generate": "drizzle-kit generate",
|
||||||
"db:migrate": "drizzle-kit migrate",
|
"db:migrate": "drizzle-kit migrate",
|
||||||
"db:push": "drizzle-kit push:pg",
|
"db:push": "drizzle-kit push:pg",
|
||||||
|
"build": "bun build --compile --minify-whitespace --minify-syntax --target bun --outfile server ./src/app.ts",
|
||||||
"dev": "bun run --watch src/app.ts"
|
"dev": "bun run --watch src/app.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
@ -14,6 +15,7 @@
|
||||||
"@elysiajs/cookie": "^0.8.0",
|
"@elysiajs/cookie": "^0.8.0",
|
||||||
"@elysiajs/cors": "^1.2.0",
|
"@elysiajs/cors": "^1.2.0",
|
||||||
"@elysiajs/swagger": "^1.2.0",
|
"@elysiajs/swagger": "^1.2.0",
|
||||||
|
"drizzle-kit": "^0.30.2",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
"drizzle-orm": "^0.38.4",
|
"drizzle-orm": "^0.38.4",
|
||||||
"elysia": "latest",
|
"elysia": "latest",
|
||||||
|
|
@ -26,7 +28,6 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/pg": "^8.11.10",
|
"@types/pg": "^8.11.10",
|
||||||
"bun-types": "latest",
|
"bun-types": "latest",
|
||||||
"drizzle-kit": "^0.30.2",
|
|
||||||
"tsx": "^4.19.2"
|
"tsx": "^4.19.2"
|
||||||
},
|
},
|
||||||
"module": "src/app.js"
|
"module": "src/app.js"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ import { api } from "./api";
|
||||||
const allowedOrigins = [
|
const allowedOrigins = [
|
||||||
"http://localhost:5175",
|
"http://localhost:5175",
|
||||||
"http://localhost:5173",
|
"http://localhost:5173",
|
||||||
"https://your-production-site.com",
|
"https://dashboard.planpostai.com",
|
||||||
|
"https://canvas.planpostai.com",
|
||||||
];
|
];
|
||||||
|
|
||||||
const app = new Elysia({
|
const app = new Elysia({
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ import { Client } from "minio";
|
||||||
import { ENV } from "../config/env";
|
import { ENV } from "../config/env";
|
||||||
|
|
||||||
export const minioClient = new Client({
|
export const minioClient = new Client({
|
||||||
endPoint: ENV.MINIO_ENDPOINT!,
|
endPoint: ENV.MINIO_ENDPOINT!,
|
||||||
port: ENV.MINIO_PORT,
|
port: ENV.MINIO_PORT,
|
||||||
useSSL: false,
|
useSSL: false,
|
||||||
accessKey: ENV.MINIO_ACCESS_KEY,
|
accessKey: ENV.MINIO_ACCESS_KEY,
|
||||||
secretKey: ENV.MINIO_SECRET_KEY,
|
secretKey: ENV.MINIO_SECRET_KEY,
|
||||||
})
|
})
|
||||||
Loading…
Add table
Reference in a new issue