add README and build scripts

This commit is contained in:
2022-08-04 19:02:33 +08:00
parent 79296a634a
commit 0fb0cdd2fd
4 changed files with 91 additions and 0 deletions

16
build/Dockerfile Normal file
View File

@ -0,0 +1,16 @@
ARG RUST_VERSION="1.62"
ARG ALPINE_VERSION="3.16"
FROM rust:${RUST_VERSION}-alpine${ALPINE_VERSION}
ARG APK_MIRROR=""
ARG CRATES_MIRROR=""
RUN [ ! -z "${APK_MIRROR}" ] && sed -i "s/dl-cdn.alpinelinux.org/${APK_MIRROR}/g" /etc/apk/repositories; apk update; apk add gcc sqlite
RUN [ ! -z "${CRATES_MIRROR}" ] && printf '[source.crates-io]\nreplace-with = "mirror"\n\n[source.mirror]\nregistry = "%s"\n' "${CRATES_MIRROR}" > $CARGO_HOME/config; true
ADD . /src
WORKDIR /src
RUN cargo build --release
FROM alpine:${ALPINE_VERSION}}
COPY --from=0 /src/target/release/rust-template /bin/rust-template
ENTRYPOINT [ "/bin/rust-template" ]