getting started and failing

This commit is contained in:
2025-05-21 22:36:29 +02:00
parent 3a6ce349d9
commit 54d0b65300
2 changed files with 62 additions and 21 deletions

View File

@ -1,33 +1,18 @@
FROM rust:1.85-slim-bookworm AS build
FROM gcc AS build
# get x86_64-unknown-linux-musl as a build target
RUN rustup target add x86_64-unknown-linux-musl
# create a new empty shell project
RUN USER=root cargo new --bin http_server
WORKDIR /http_server
# copy over your manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY ./main.c .
COPY ./libstrops.a .
# this build step will cache your dependencies
RUN cargo build --release
RUN rm src/*.rs
RUN gcc -I . -L. -static -ansi -O2 -o http_server main.c -lstrops
# copy your source tree
COPY ./src ./src
# build for release as a static-pie linked binary
RUN rm ./target/release/deps/http_server*
ENV RUSTFLAGS='-C target-feature=+crt-static'
RUN cargo build --release --target x86_64-unknown-linux-musl
RUN strip /http_server/target/x86_64-unknown-linux-musl/release/http_server
RUN strip ./http_server
FROM scratch
# copy the build artifact from the build stage
COPY --from=build /http_server/target/x86_64-unknown-linux-musl/release/http_server /
COPY --from=build /http_server /
COPY ./www /www
COPY ./internal /internal