-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
67 lines (50 loc) · 1.85 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
FROM rust:1.83-slim-bookworm as chef
RUN apt-get update -y && \
apt-get install --no-install-recommends -y pkg-config make g++ libssl-dev curl jq && \
rustup target add x86_64-unknown-linux-gnu && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Install cargo-chef
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
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release -p scotty -p scottyctl
FROM node:22 as frontend-builder
WORKDIR /app
COPY ./frontend /app
RUN yarn install && yarn build
FROM debian:bookworm-slim
ARG APP=/app
RUN apt-get update \
&& apt-get --no-install-recommends install -y curl ca-certificates tzdata \
&& rm -rf /var/lib/apt/lists/*
# install docker
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -fsSL https://get.docker.com | bash
# Set the Docker Compose version to install
ENV DOCKER_COMPOSE_VERSION=2.29.0
# Download and install Docker Compose
RUN curl -L "https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose
EXPOSE 21342
ENV TZ=Etc/UTC \
APP_USER=appuser
RUN groupadd $APP_USER \
&& useradd -g $APP_USER $APP_USER \
&& mkdir -p ${APP}
COPY --from=builder /app/target/release/scotty ${APP}/scotty
COPY --from=builder /app/target/release/scottyctl ${APP}/scottyctl
COPY --from=builder /app/config ${APP}/config
COPY --from=frontend-builder /app/build ${APP}/frontend/build
# RUN chown -R $APP_USER:$APP_USER ${APP}
# USER $APP_USER
WORKDIR ${APP}
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:21342/api/v1/health || exit 1
ENV RUST_LOG=api
CMD ["./scotty"]