Skip to content

Commit

Permalink
chore: dockerization
Browse files Browse the repository at this point in the history
  • Loading branch information
szattila98 committed Jun 30, 2023
1 parent da2d673 commit c686f53
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"dev": "nuxt dev --port=4000",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3.9'

services:
server:
container_name: binge-at-home-server
build:
context: ./server
dockerfile: ../docker/server/Dockerfile
ports:
- "8000:8000"

client:
container_name: binge-at-home-client
build:
context: ./client
dockerfile: ../docker/client/Dockerfile
ports:
- "4000:4000"
environment:
- PORT=4000
depends_on:
- server
20 changes: 20 additions & 0 deletions docker/client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:20.2.0-bullseye-slim as builder

WORKDIR /app
COPY . ./

RUN npm ci --no-audit
RUN npm run build

FROM node:20.2.0-bullseye-slim

WORKDIR /app

COPY --from=builder /app/package*.json ./
COPY --from=builder /app/.output ./

# clean install dependencies, no devDependencies, no prepare script
RUN npm ci --omit=dev --ignore-scripts --no-audit --loglevel verbose

EXPOSE 3000
CMD ["node", "./server/index.mjs"]
17 changes: 17 additions & 0 deletions docker/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM lukemathwalker/cargo-chef:latest-rust-1-alpine AS chef
WORKDIR /app

FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release --bin binge-at-home

FROM debian:bullseye AS runtime
WORKDIR /app
COPY --from=builder /app/target/release/binge-at-home /usr/local/bin
ENTRYPOINT ["/usr/local/bin/binge-at-home"]

0 comments on commit c686f53

Please # to comment.