mirror of
https://github.com/garentyler/inferno.git
synced 2025-07-19 11:50:41 -06:00
Combine dev and prod dockerfiles
This commit is contained in:
parent
641fccfd60
commit
a85422d513
@ -2,4 +2,9 @@
|
|||||||
Inferno is a decentralized alternative to Discord.
|
Inferno is a decentralized alternative to Discord.
|
||||||
Inferno is licensed under GPLv3.
|
Inferno is licensed under GPLv3.
|
||||||
|
|
||||||
|
## Running
|
||||||
|
- dev: `docker compose up --build`
|
||||||
|
- prod: `docker compose -f docker-compose.yml -f docker-compose.prod.yml up --build`
|
||||||
|
|
||||||
|
|
||||||
Dockerfiles linted using [hadolint](https://github.com/hadolint/hadolint).
|
Dockerfiles linted using [hadolint](https://github.com/hadolint/hadolint).
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
FROM node:23.3.0-alpine3.20 AS builder
|
FROM node:23.3.0-alpine3.20 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json .
|
COPY package.json .
|
||||||
RUN npm install
|
RUN npm install
|
||||||
ENV PATH=/app/node_modules/.bin:$PATH
|
ENV PATH=/app/node_modules/.bin:$PATH
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
FROM base AS dev
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["npm", "run", "dev", "--", "--host"]
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM nginx:1.27.3-alpine3.20
|
FROM nginx:1.27.3-alpine3.20 AS prod
|
||||||
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
COPY --from=builder /app/dist /var/www/html/
|
COPY --from=builder /app/dist /var/www/html/
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
@ -1,8 +0,0 @@
|
|||||||
FROM node:23.3.0-alpine3.20
|
|
||||||
WORKDIR /app
|
|
||||||
COPY package.json .
|
|
||||||
ENV PATH=/app/node_modules/.bin:$PATH
|
|
||||||
RUN npm install
|
|
||||||
COPY . .
|
|
||||||
EXPOSE 3000
|
|
||||||
CMD ["npm", "run", "dev", "--", "--host"]
|
|
11
docker-compose.prod.yml
Normal file
11
docker-compose.prod.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
services:
|
||||||
|
client-web:
|
||||||
|
build:
|
||||||
|
target: prod
|
||||||
|
volumes: !reset []
|
||||||
|
server:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: server/Dockerfile
|
||||||
|
target: prod
|
||||||
|
volumes: !reset []
|
@ -3,7 +3,8 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
build:
|
build:
|
||||||
context: ./clients/web/
|
context: ./clients/web/
|
||||||
dockerfile: dev.Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
target: dev
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
volumes:
|
volumes:
|
||||||
@ -13,7 +14,8 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
build:
|
build:
|
||||||
context: ./server/
|
context: ./server/
|
||||||
dockerfile: dev.Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
target: dev
|
||||||
ports:
|
ports:
|
||||||
- "3001:3001"
|
- "3001:3001"
|
||||||
volumes:
|
volumes:
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
# Build from /, not /server.
|
FROM rust:1.82.0-alpine3.20 AS base
|
||||||
# Use cargo chef to cache built dependencies.
|
|
||||||
FROM rust:1.82.0-alpine3.20 AS chef
|
|
||||||
RUN apk add --no-cache musl-dev=1.2.5-r0 git=2.45.2-r0
|
RUN apk add --no-cache musl-dev=1.2.5-r0 git=2.45.2-r0
|
||||||
RUN cargo install cargo-chef --locked --version 0.1.68
|
RUN cargo install cargo-chef --locked --version 0.1.68
|
||||||
|
RUN cargo install cargo-watch --locked --version 8.5.3
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN git config --global --add safe.directory /app
|
RUN git config --global --add safe.directory /app
|
||||||
|
|
||||||
FROM chef AS planner
|
FROM base AS dev
|
||||||
|
EXPOSE 3001
|
||||||
|
CMD ["cargo", "watch", "-x", "run"]
|
||||||
|
|
||||||
|
FROM base AS planner
|
||||||
COPY server/Cargo.toml .
|
COPY server/Cargo.toml .
|
||||||
COPY server/Cargo.lock .
|
COPY server/Cargo.lock .
|
||||||
RUN cargo chef prepare --recipe-path recipe.json
|
RUN cargo chef prepare --recipe-path recipe.json
|
||||||
|
|
||||||
FROM chef AS builder
|
FROM base AS builder
|
||||||
COPY --from=planner /app/recipe.json recipe.json
|
COPY --from=planner /app/recipe.json recipe.json
|
||||||
RUN cargo chef cook --release --recipe-path recipe.json
|
RUN cargo chef cook --release --recipe-path recipe.json
|
||||||
COPY server .
|
COPY server .
|
||||||
@ -19,8 +22,7 @@ COPY .git .git
|
|||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
RUN strip target/release/inferno
|
RUN strip target/release/inferno
|
||||||
|
|
||||||
# Multi-stage build to minimize container size
|
FROM alpine:3.20 AS prod
|
||||||
FROM alpine:3.20
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder /app/target/release/inferno .
|
COPY --from=builder /app/target/release/inferno .
|
||||||
EXPOSE 3001
|
EXPOSE 3001
|
@ -1,7 +0,0 @@
|
|||||||
FROM rust:1.82.0-alpine3.20
|
|
||||||
RUN apk add --no-cache musl-dev=1.2.5-r0 git=2.45.2-r0
|
|
||||||
RUN cargo install cargo-watch --locked --version 8.5.3
|
|
||||||
WORKDIR /app
|
|
||||||
RUN git config --global --add safe.directory /app
|
|
||||||
EXPOSE 3001
|
|
||||||
CMD ["cargo", "watch", "-x", "run"]
|
|
Loading…
x
Reference in New Issue
Block a user