This repository has been archived by the owner on Jan 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
47 lines (36 loc) · 1.5 KB
/
Dockerfile
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
41
42
43
44
45
46
47
# Using multistage build:
# https://docs.docker.com/develop/develop-images/multistage-build/
# https://whitfin.io/speeding-up-rust-docker-builds/
########################## BUILD IMAGE ##########################
# Rust build image to build Autarco Scraper's statically compiled binary
FROM docker.io/rust:1 as builder
# Build the dependencies first
RUN USER=root cargo new --bin autarco-scraper
WORKDIR /usr/src/autarco-scraper
COPY ./Cargo.* ./
RUN cargo build --release
RUN rm src/*.rs
# Add the real project files from current folder
ADD . ./
# Build the actual binary from the copied local files
RUN rm ./target/release/deps/autarco_scraper*
RUN cargo build --release
########################## RUNTIME IMAGE ##########################
# Create new stage with a minimal image for the actual runtime image/container
FROM docker.io/debian:bullseye-slim
# Install CA certificates
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Copy the binary from the "builder" stage to the current stage
RUN adduser --system --disabled-login --home /autarco-scraper --gecos "" --shell /bin/bash autarco-scraper
COPY --from=builder /autarco-scraper/target/release/autarco-scraper /autarco-scraper
# Standard port on which Rocket launches
EXPOSE 8000
# Set user to www-data
USER autarco-scraper
# Set container home directory
WORKDIR /autarco-scraper
# Run Autarco Scraper
ENTRYPOINT [ "/autarco-scraper/autarco-scraper" ]