2020-06-07 20:21:25 +00:00
|
|
|
# Build
|
2020-06-07 22:29:22 +00:00
|
|
|
FROM ekidd/rust-musl-builder:1.44.0 as rust
|
2020-06-07 20:21:25 +00:00
|
|
|
|
|
|
|
# Cache deps
|
|
|
|
WORKDIR /app
|
|
|
|
RUN sudo chown -R rust:rust .
|
|
|
|
RUN USER=root cargo new server
|
|
|
|
WORKDIR /app/server
|
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
|
|
RUN sudo chown -R rust:rust .
|
|
|
|
RUN mkdir -p ./src/bin \
|
|
|
|
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
|
|
|
|
RUN cargo build --release
|
|
|
|
RUN rm -f ./target/x86_64-unknown-linux-musl/release/deps/pict_rs*
|
|
|
|
COPY src ./src/
|
|
|
|
|
|
|
|
# Build for release
|
|
|
|
RUN cargo build --frozen --release
|
|
|
|
|
2020-06-07 22:29:22 +00:00
|
|
|
FROM alpine:3.11
|
2020-06-07 20:21:25 +00:00
|
|
|
|
|
|
|
# Copy resources
|
|
|
|
COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/release/pict-rs /app/pict-rs
|
|
|
|
|
|
|
|
RUN addgroup -g 1000 pictrs
|
|
|
|
RUN adduser -D -s /bin/sh -u 1000 -G pictrs pictrs
|
|
|
|
RUN chown pictrs:pictrs /app/pict-rs
|
|
|
|
USER pictrs
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["/app/pict-rs"]
|