docker compose
This commit is contained in:
parent
cf488101a0
commit
f110d82402
3
Containerfile
Normal file
3
Containerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM alpine
|
||||
COPY build/server /
|
||||
ENTRYPOINT ["/server"]
|
34
compose.yaml
Normal file
34
compose.yaml
Normal file
@ -0,0 +1,34 @@
|
||||
version: '3.9'
|
||||
networks:
|
||||
maps-service-network:
|
||||
driver: bridge
|
||||
|
||||
services:
|
||||
nats:
|
||||
image: docker.io/nats:latest
|
||||
container_name: nats
|
||||
networks:
|
||||
- maps-service-network
|
||||
|
||||
maps-service:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Containerfile
|
||||
container_name: maps-service
|
||||
networks:
|
||||
- maps-service-network
|
||||
|
||||
web:
|
||||
build:
|
||||
context: web
|
||||
dockerfile: Containerfile
|
||||
networks:
|
||||
- maps-service-network
|
||||
|
||||
validation:
|
||||
build:
|
||||
context: validation
|
||||
dockerfile: Containerfile
|
||||
container_name: validation
|
||||
networks:
|
||||
- maps-service-network
|
23
validation/Containerfile
Normal file
23
validation/Containerfile
Normal file
@ -0,0 +1,23 @@
|
||||
# Using the `rust-musl-builder` as base image, instead of
|
||||
# the official Rust toolchain
|
||||
FROM docker.io/clux/muslrust:stable AS chef
|
||||
USER root
|
||||
RUN cargo install cargo-chef
|
||||
WORKDIR /app
|
||||
|
||||
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
|
||||
# Notice that we are specifying the --target flag!
|
||||
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
|
||||
COPY . .
|
||||
RUN cargo build --release --target x86_64-unknown-linux-musl --bin maps-validation
|
||||
|
||||
FROM docker.io/alpine:latest AS runtime
|
||||
RUN addgroup -S myuser && adduser -S myuser -G myuser
|
||||
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/maps-validation /usr/local/bin/
|
||||
USER myuser
|
||||
ENTRYPOINT ["/usr/local/bin/maps-validation"]
|
38
web/Containerfile
Normal file
38
web/Containerfile
Normal file
@ -0,0 +1,38 @@
|
||||
# use the official Bun image
|
||||
# see all versions at https://hub.docker.com/r/oven/bun/tags
|
||||
FROM oven/bun:1 AS base
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# install dependencies into temp directory
|
||||
# this will cache them and speed up future builds
|
||||
FROM base AS install
|
||||
RUN mkdir -p /temp/dev
|
||||
COPY package.json bun.lockb /temp/dev/
|
||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
||||
|
||||
# install with --production (exclude devDependencies)
|
||||
RUN mkdir -p /temp/prod
|
||||
COPY package.json bun.lockb /temp/prod/
|
||||
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||
|
||||
# copy node_modules from temp directory
|
||||
# then copy all (non-ignored) project files into the image
|
||||
FROM base AS prerelease
|
||||
COPY --from=install /temp/dev/node_modules node_modules
|
||||
COPY . .
|
||||
|
||||
# [optional] tests & build
|
||||
ENV NODE_ENV=production
|
||||
RUN bun test
|
||||
RUN bun run build
|
||||
|
||||
# copy production dependencies and source code into final image
|
||||
FROM base AS release
|
||||
COPY --from=install /temp/prod/node_modules node_modules
|
||||
COPY --from=prerelease /usr/src/app/index.ts .
|
||||
COPY --from=prerelease /usr/src/app/package.json .
|
||||
|
||||
# run the app
|
||||
USER bun
|
||||
EXPOSE 3000/tcp
|
||||
ENTRYPOINT [ "bun", "run", "index.ts" ]
|
Loading…
Reference in New Issue
Block a user