diff --git a/api/.env.example b/api/.env.example index 9df7716..a2c868d 100644 --- a/api/.env.example +++ b/api/.env.example @@ -1,5 +1,5 @@ PORT= -MONGO_URI= +MONGO_URI=mongodb://textbee-db:27017/textbee JWT_SECRET=secret JWT_EXPIRATION=60d @@ -17,4 +17,4 @@ MAIL_PORT= MAIL_USER= MAIL_PASS= MAIL_FROM= -MAIL_REPLY_TO=textbee.dev@gmail.com \ No newline at end of file +MAIL_REPLY_TO=textbee.dev@gmail.com diff --git a/api/Dockerfile b/api/Dockerfile index 0cb9adb..47044a5 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -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 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..e082a70 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,36 @@ +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: + - textbee-db + textbee-db: + image: mongo + container_name: textbee-db + volumes: + - textbee-db-data:/data/db + ports: + - "27017:27017" + +volumes: + textbee-db-data: diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000..19e926e --- /dev/null +++ b/web/Dockerfile @@ -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"] \ No newline at end of file