diff --git a/.dockerignore b/.dockerignore index 7e8f23aa..5c6b5846 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,9 @@ **/target/ **/node_modules/ crates/web/frontend/pkg -Dockerfile +**Dockerfile docker-compose.yml LICENSE -README.md \ No newline at end of file +README.md +# we do our own version pinning in the Dockerfile +rust-toolchain.toml diff --git a/docker-compose.yml b/docker-compose.yml index 8422e64e..0c45cf37 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/Dockerfile b/docker/playground.Dockerfile similarity index 97% rename from Dockerfile rename to docker/playground.Dockerfile index 9d110242..5b9f13d0 100644 --- a/Dockerfile +++ b/docker/playground.Dockerfile @@ -1,4 +1,5 @@ -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 @@ -6,7 +7,6 @@ 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 . . diff --git a/docker/server.Dockerfile b/docker/server.Dockerfile new file mode 100644 index 00000000..db1acf20 --- /dev/null +++ b/docker/server.Dockerfile @@ -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" ]