-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,57 @@ | ||
FROM rustlang/rust:nightly-bullseye | ||
|
||
WORKDIR /app | ||
|
||
COPY ./. . | ||
#################################################################################################### | ||
## Builder | ||
#################################################################################################### | ||
FROM rustlang/rust:nightly-bullseye AS builder | ||
RUN apt update && apt install -y libssl-dev pkg-config libz-dev libcurl4 postgresql | ||
RUN update-ca-certificates | ||
|
||
# Create appuser | ||
ENV USER=bot | ||
ENV UID=10001 | ||
|
||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
|
||
WORKDIR /bot | ||
|
||
COPY ./ . | ||
|
||
RUN cargo install diesel_cli --no-default-features --features postgres | ||
|
||
RUN cargo build --release | ||
|
||
RUN cp ./target/release/cleaner ./cleaner | ||
#################################################################################################### | ||
## Final image | ||
#################################################################################################### | ||
FROM debian:bullseye-slim | ||
|
||
RUN apt update && apt install -y postgresql | ||
|
||
# Import from builder. | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /etc/group /etc/group | ||
|
||
WORKDIR /bot | ||
|
||
# Copy our build | ||
COPY --from=builder /bot/target/release/el_monitorro ./ | ||
COPY --from=builder /bot/target/release/deliver ./ | ||
COPY --from=builder /bot/target/release/sync ./ | ||
COPY --from=builder /bot/target/release/cleaner ./ | ||
|
||
RUN cp ./target/release/sync ./sync | ||
COPY --from=builder /bot/docker/start.sh ./ | ||
|
||
RUN cp ./target/release/el_monitorro ./el_monitorro | ||
COPY --from=builder /usr/local/cargo/bin/diesel ./ | ||
COPY --from=builder /bot/migrations/ ./migrations/ | ||
|
||
RUN cp ./target/release/deliver ./deliver | ||
|
||
RUN rm -rf ./target | ||
# Use an unprivileged user. | ||
USER bot:bot | ||
|
||
CMD ["bash", "/app/docker/start.sh"] | ||
CMD ["bash", "/bot/start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters