Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker Compose setup #34

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PORT=
MONGO_URI=
MONGO_URI=mongodb://mongo:27017/textbee
JWT_SECRET=secret
JWT_EXPIRATION=60d

4 changes: 2 additions & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine AS base
FROM node:lts-alpine AS base
RUN npm i -g pnpm
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
@@ -13,7 +13,7 @@ FROM base AS build
ENV NODE_ENV=production
RUN pnpm build

FROM node:18-alpine AS prod
FROM node:lts-alpine AS prod
ENV NODE_ENV=production
WORKDIR /app
RUN npm i -g pnpm
31 changes: 31 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
textbee-web:
image: textbee-web
container_name: textbee-web
build:
context: ./web
dockerfile: Dockerfile
ports:
- "3000:3000"
env_file:
- path: ./web/.env
required: true
command: pnpm start
textbee-api:
image: textbee-api
container_name: textbee-api
build:
context: ./api
dockerfile: Dockerfile
ports:
- "3005:3005"
env_file:
- path: ./api/.env
required: true
depends_on:
- mongo
mongo:
image: mongo
container_name: mongo
ports:
- "27017:27017"
18 changes: 18 additions & 0 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:lts-alpine AS base

# Stage 1: Install web dependencies
FROM base AS web-deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable pnpm && pnpm install --frozen-lockfile

# Stage 2: Build the web application
FROM base AS web-builder
ENV NODE_ENV=production
EXPOSE 3000
WORKDIR /app
COPY . .
COPY --from=web-deps /app/node_modules ./node_modules
RUN corepack enable pnpm && pnpm run vercel-build

CMD ["pnpm", "start"]