DEVELOPMENT ENVIRONMENT

~liljamo/wallhavenapirandom

ce74b238541c74700bc23ffdd6659e089f887c8a — Jonni Liljamo 1 year, 8 months ago 1ef5d36
feat: dockerius filius
1 files changed, 40 insertions(+), 0 deletions(-)

A Dockerfile
A Dockerfile => Dockerfile +40 -0
@@ 0,0 1,40 @@
## builder
FROM rust:1.66.1-slim as builder

WORKDIR /usr/src

# weewoo deps for cross-compiling to musl
RUN apt-get update
RUN apt-get install musl-tools libssl-dev build-essential -y

# create blank proj
RUN USER=root cargo new wallhavenapirandom

# copy deps
COPY Cargo.toml Cargo.lock /usr/src/wallhavenapirandom/

WORKDIR /usr/src/wallhavenapirandom

# install cross-compile target (alpine)
RUN rustup target add x86_64-unknown-linux-musl

# build deps so they're cached
RUN cargo build --target x86_64-unknown-linux-musl --release

# copy shit sauce
COPY src /usr/src/wallhavenapirandom/src/

# touch the file inappropriately to prevent a cached build, because apparently this is an issue sometimes, haven't verified, too tired
RUN touch /usr/src/wallhavenapirandom/src/main.rs

# build
RUN cargo build --target x86_64-unknown-linux-musl --release


## runtime
FROM alpine:3.17.1 AS runtime 

COPY --from=builder /usr/src/wallhavenapirandom/target/x86_64-unknown-linux-musl/release/wallhavenapirandom /usr/local/bin

EXPOSE 3000
CMD ["/usr/local/bin/wallhavenapirandom"]