Skip to content

Commit

Permalink
try to fix deps
Browse files Browse the repository at this point in the history
  • Loading branch information
TOwInOK committed Oct 27, 2024
1 parent 43e0bcb commit 4549d6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,4 @@ panic = "abort"
debug = false
[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "target-feature=+crt-static"]

[target.aarch64-unknown-linux-musl]
rustflags = ["-C", "target-feature=+crt-static"]
linker = "gcc"
25 changes: 15 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@ ENV PATH="/root/.cargo/bin:${PATH}"
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
ENV CARGO_HTTP_MULTIPLEXING=false
ENV RUST_TARGET=x86_64-unknown-linux-musl

ENV RUSTFLAGS="-C target-feature=+crt-static"
ENV CC="gcc"
ENV AR="ar"
ENV CFLAGS="-I/usr/include"
ENV LDFLAGS="-L/usr/lib"
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 \
pkgconfig \
curl \
gcc \
make \
curl \
perl \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
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 ./
Expand All @@ -32,19 +37,19 @@ RUN mkdir src && \
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
COPY --from=builder /app/target/release/shuller_bot .
# 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
USER appuser
CMD ["./shuller_bot"]

0 comments on commit 4549d6b

Please sign in to comment.