generated from alecodes/base-template
build: add docker build files
This commit is contained in:
parent
1871610770
commit
3c2d3cf720
6 changed files with 262 additions and 23 deletions
43
Dockerfile
Normal file
43
Dockerfile
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
# ── Javascript ──────────────────────────────────────────────────────────
|
||||
|
||||
FROM oven/bun:1 AS base-js
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# install dependencies into temp directory
|
||||
# this will cache them and speed up future builds
|
||||
FROM base-js AS install
|
||||
COPY package.json bun.lock /temp/dev/
|
||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
||||
|
||||
# copy node_modules from temp directory
|
||||
# then copy all (non-ignored) project files into the image
|
||||
FROM base-js AS prerelease
|
||||
COPY --from=install /temp/dev/node_modules node_modules
|
||||
COPY frontend frontend
|
||||
COPY .devfiles/scripts/build-frontend.ts .devfiles/scripts/build-frontend.ts
|
||||
|
||||
ENV NODE_ENV=production
|
||||
RUN bun ./.devfiles/scripts/build-frontend.ts
|
||||
|
||||
# ── Rust ────────────────────────────────────────────────────────────────
|
||||
|
||||
FROM rust:slim AS base-rust
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
COPY --from=prerelease /usr/src/app/dist dist
|
||||
|
||||
RUN cargo build --locked --release
|
||||
|
||||
FROM scratch AS runner
|
||||
|
||||
ENV RUST_LOG="compendium=debug,info"
|
||||
|
||||
COPY --from=base-rust /app/target/release/compendium /
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENTRYPOINT ["./compendium"]
|
||||
CMD ["./compendium"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue