Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dockerfile #136

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*/.git
client/node_modules
server/target
29 changes: 15 additions & 14 deletions server/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -2,24 +2,23 @@

FROM node:22 AS frontend-builder

WORKDIR /app
WORKDIR /app/client

COPY client/package.json client/package-lock.json /app/client/
RUN --mount=type=cache,target=/root/.npm,sharing=locked \
--mount=type=cache,target=/app/node_modules,sharing=locked \
--mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
npm ci
npm i

COPY client /app/client
RUN --mount=type=cache,target=/root/.npm,sharing=locked \
--mount=type=cache,target=/app/node_modules,sharing=locked \
--mount=type=bind,source=.,target=. \
npm run build

FROM rust:bookworm AS backend-builder

ARG PROTOC_VERSION=29.3

WORKDIR /app
WORKDIR /app/server

RUN PROTOC_ZIP="protoc-${PROTOC_VERSION}-linux-x86_64.zip" \
&& curl -fvL -o "/tmp/${PROTOC_ZIP}" \
@@ -28,24 +27,26 @@ RUN PROTOC_ZIP="protoc-${PROTOC_VERSION}-linux-x86_64.zip" \
&& unzip -o "/tmp/${PROTOC_ZIP}" -d /usr/local 'include/*' \
&& rm -f "/tmp/${PROTOC_ZIP}"

ENV CARGO_TARGET_DIR=/artifact \
RUSTUP_HOME=/var/cache/rustup \
CARGO_HOME=/var/cache/cargo
ENV CARGO_TARGET_DIR=/artifact
ENV RUSTUP_HOME=/var/cache/rustup
ENV CARGO_HOME=/var/cache/cargo

RUN --mount=type=cache,target=/var/cache/rustup,sharing=locked \
--mount=type=bind,source=.,target=. \
--mount=type=bind,source=./server,target=/app/server \
--mount=type=bind,source=./proto,target=/app/proto \
rustup show

RUN --mount=type=cache,target=/var/cache/rustup,sharing=locked \
--mount=type=cache,target=/var/cache/cargo,sharing=locked \
--mount=type=bind,source=.,target=. \
cd server && cargo build --release --locked
--mount=type=bind,source=./server,target=/app/server \
--mount=type=bind,source=./proto,target=/app/proto \
cargo build --release --locked

FROM debian:bookworm-slim AS server-debian-slim

WORKDIR /srv
ENV FRONTEND_DIST_DIR /srv/frontend/dist
COPY --from=frontend-builder /app/dist ${FRONTEND_DIST_DIR}
ENV FRONTEND_DIST_DIR=/srv/frontend/dist
COPY --from=frontend-builder /app/client/dist ${FRONTEND_DIST_DIR}
COPY --from=backend-builder /artifact/release/h24w14 /srv/bin/h24w14

CMD [ "/srv/bin/h24w14" ]