-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
55 lines (48 loc) · 1.45 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
FROM alpine:latest AS base
ENV PATH="/root/.cargo/bin:${PATH}"
ENV RUST_TARGET=x86_64-unknown-linux-musl
# ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
# ENV CARGO_HTTP_MULTIPLEXING=false
# ENV PKG_CONFIG_ALLOW_CROSS=1
# ENV OPENSSL_STATIC=1
# ENV OPENSSL_DIR=/usr
RUN apk add --no-cache \
build-base \
musl-dev \
openssl-dev \
openssl-libs-static \
gcc \
curl \
perl \
make \
&& curl --proto '=https' --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- -y \
--profile minimal \
--default-toolchain stable \
--target ${RUST_TARGET} \
&& ~/.cargo/bin/cargo install cargo-chef --locked
# Planning stage
FROM base AS planner
WORKDIR /app
COPY Cargo.toml ./
RUN mkdir src && \
echo "fn main() {}" > src/main.rs && \
cargo generate-lockfile && \
cargo chef prepare --recipe-path recipe.json
# Builder stage
FROM base AS builder
WORKDIR /app
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --target ${RUST_TARGET} --recipe-path recipe.json
COPY . .
RUN cargo build --release --target ${RUST_TARGET}
# Final stage
FROM alpine:latest
WORKDIR /app
RUN apk add --no-cache ca-certificates openssl
# Changed path to include the target architecture
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/shuller_bot .
RUN addgroup -S appgroup && adduser -S appuser -G appgroup \
&& chown appuser:appgroup /app/shuller_bot \
&& chmod +x /app/shuller_bot
USER appuser
CMD ["./shuller_bot"]