Skip to content

Commit

Permalink
feat(server): add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgehermo9 committed Oct 10, 2024
1 parent 774d90a commit 37d00fa
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
**/target/
**/node_modules/
crates/web/frontend/pkg
Dockerfile
**Dockerfile
docker-compose.yml
LICENSE
README.md
README.md
# we do our own version pinning in the Dockerfile
rust-toolchain.toml
21 changes: 20 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
services:
gq-playground:
build: ./
build:
context: .
dockerfile: docker/playground.Dockerfile
image: gq-playground
ports:
- 3000:3000
gq-server:
build:
context: .
dockerfile: docker/server.Dockerfile
image: gq-server
ports:
- 3001:3000
environment:
DATABASE_URL: postgres://postgres:password@db:5432/db
depends_on:
- db
db:
image: docker.io/postgres:16
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: db
4 changes: 2 additions & 2 deletions Dockerfile → docker/playground.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM rust:1.80 AS chef
FROM rust:1.81 AS chef
WORKDIR /app
# `wasm-pack` dependency `libz-ng-sys 1.1.15` needs cmake
# Remember to delete this once `libz-ng-sys 1.1.17` is used, since
# it doesn't need cmake https://github.com/rust-lang/libz-sys/releases/tag/1.1.17
RUN apt-get update && apt-get install -y cmake
RUN cargo install cargo-chef --version 0.1.67 --locked
RUN cargo install wasm-pack --version 0.13.0 --locked
RUN rustup target add wasm32-unknown-unknown
WORKDIR /app

FROM chef AS planner
COPY . .
Expand Down
18 changes: 18 additions & 0 deletions docker/server.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM rust:1.81 AS chef
WORKDIR /app
RUN cargo install cargo-chef --version 0.1.67 --locked

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 --package gq-server --release --recipe-path recipe.json
COPY . .
RUN cargo build --package gq-server --release

FROM debian:bookworm
WORKDIR /app
COPY --from=builder /app/target/release/gq-server .
CMD [ "./gq-server" ]

0 comments on commit 37d00fa

Please sign in to comment.