DEVELOPMENT ENVIRONMENT

~liljamo/wallhavenapirandom

ref: e987e8714a6c9e92b5c519cf3b0f476d58a293d0 wallhavenapirandom/Dockerfile -rw-r--r-- 1.1 KiB
e987e871Jonni Liljamo feat: serve the image straight, dont redirect 1 year, 10 months ago
                                                                                
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
## 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"]