update dockerfile

This commit is contained in:
Freya Murphy 2023-06-29 11:54:24 -04:00
parent f5fcce110a
commit 504a7669bf
4 changed files with 22 additions and 9 deletions

View file

@ -1,3 +1,6 @@
/deployments /deployments
/target /server/target
/client/node_modules
/client/package.json
/client/package-lock.json
/.git /.git

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -1,16 +1,23 @@
FROM rust:alpine AS builder FROM rust:alpine AS builder-rs
COPY Cargo.toml Cargo.lock /app/ COPY server/Cargo.toml server/Cargo.lock /app/
COPY src /app/src COPY server/src /app/src
WORKDIR /app WORKDIR /app
RUN apk add musl-dev RUN apk add musl-dev
RUN cargo build --release RUN cargo build --release
FROM node:alpine AS builder-ts
COPY client /app/
WORKDIR /app
RUN npm install typescript
RUN npx tsc
FROM alpine FROM alpine
RUN apk add --no-cache tini RUN apk add --no-cache tini
RUN adduser -DH block RUN adduser -DH block
USER block USER block
COPY --from=builder /app/target/release/rollback /rollback COPY --from=builder-rs /app/target/release/rollback /rollback
COPY client /client COPY --from=builder-ts /app /client
ENV CLIENT_DIR=/client
ENTRYPOINT ["/sbin/tini", "--", "/rollback"] ENTRYPOINT ["/sbin/tini", "--", "/rollback"]

View file

@ -12,11 +12,14 @@ use super::rooms;
pub fn routes() -> Router { pub fn routes() -> Router {
let room_server: rooms::RoomService = rooms::start_room_server(); let room_server: rooms::RoomService = rooms::start_room_server();
let client_dir = std::env::var("CLIENT_DIR").unwrap_or_else(|_| String::from("./client"));
println!("Service client data from: {client_dir}");
Router::new() Router::new()
.route("/api/check", get(|| async {"ok"})) .route("/api/check", get(|| async {"ok"}))
.route("/api/exists/:code", get(game_exists)) .route("/api/exists/:code", get(game_exists))
.route("/api/join/:code", get(game_join)) .route("/api/join/:code", get(game_join))
.nest_service("/", ServeDir::new("../client")) .nest_service("/", ServeDir::new(client_dir))
.layer(Extension(room_server)) .layer(Extension(room_server))
} }