31 lines
907 B
Docker
31 lines
907 B
Docker
|
FROM postgres as builder
|
||
|
|
||
|
ENV POSTGRES_USER "datatrash"
|
||
|
ENV POSTGRES_PASSWORD "secure"
|
||
|
|
||
|
RUN apt-get update
|
||
|
RUN apt-get install --yes curl build-essential
|
||
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-install.sh
|
||
|
RUN sh rustup-install.sh -y
|
||
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
||
|
RUN rustup target add x86_64-unknown-linux-musl
|
||
|
|
||
|
ENV USER rust
|
||
|
WORKDIR /
|
||
|
RUN cargo new --bin datatrash
|
||
|
WORKDIR /datatrash
|
||
|
COPY Cargo.lock Cargo.lock
|
||
|
COPY Cargo.toml Cargo.toml
|
||
|
RUN cargo build --release --target=x86_64-unknown-linux-musl --features vendored
|
||
|
RUN rm src/*.rs
|
||
|
|
||
|
COPY src src
|
||
|
ENV DATABASE_URL "postgresql://datatrash:secure@localhost"
|
||
|
RUN rm target/release/deps/datatrash*
|
||
|
RUN cargo build --release --target=x86_64-unknown-linux-musl --features vendored
|
||
|
RUN strip target/release/horrible
|
||
|
|
||
|
FROM SCRATCH
|
||
|
COPY --from=builder /datatrash/target/release/datatrash /datatrash
|
||
|
ENTRYPOINT ["/datatrash"]
|