update dockerfile
This commit is contained in:
parent
f5fcce110a
commit
504a7669bf
4 changed files with 22 additions and 9 deletions
|
@ -1,3 +1,6 @@
|
|||
/deployments
|
||||
/target
|
||||
/server/target
|
||||
/client/node_modules
|
||||
/client/package.json
|
||||
/client/package-lock.json
|
||||
/.git
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.5 KiB |
|
@ -1,16 +1,23 @@
|
|||
FROM rust:alpine AS builder
|
||||
FROM rust:alpine AS builder-rs
|
||||
|
||||
COPY Cargo.toml Cargo.lock /app/
|
||||
COPY src /app/src
|
||||
COPY server/Cargo.toml server/Cargo.lock /app/
|
||||
COPY server/src /app/src
|
||||
WORKDIR /app
|
||||
RUN apk add musl-dev
|
||||
RUN cargo build --release
|
||||
|
||||
FROM node:alpine AS builder-ts
|
||||
COPY client /app/
|
||||
WORKDIR /app
|
||||
RUN npm install typescript
|
||||
RUN npx tsc
|
||||
|
||||
FROM alpine
|
||||
RUN apk add --no-cache tini
|
||||
|
||||
RUN adduser -DH block
|
||||
USER block
|
||||
COPY --from=builder /app/target/release/rollback /rollback
|
||||
COPY client /client
|
||||
COPY --from=builder-rs /app/target/release/rollback /rollback
|
||||
COPY --from=builder-ts /app /client
|
||||
|
||||
ENV CLIENT_DIR=/client
|
||||
ENTRYPOINT ["/sbin/tini", "--", "/rollback"]
|
||||
|
|
|
@ -12,11 +12,14 @@ use super::rooms;
|
|||
pub fn routes() -> Router {
|
||||
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()
|
||||
.route("/api/check", get(|| async {"ok"}))
|
||||
.route("/api/exists/:code", get(game_exists))
|
||||
.route("/api/join/:code", get(game_join))
|
||||
.nest_service("/", ServeDir::new("../client"))
|
||||
.nest_service("/", ServeDir::new(client_dir))
|
||||
.layer(Extension(room_server))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue