-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
41 lines (34 loc) · 1.39 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
FROM archlinux/base:latest AS sms-irc-compiled
# update OS
RUN pacman -Syu --noconfirm
RUN pacman -S --needed --noconfirm base-devel postgresql-libs
# install Rust: download rustup
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y
# The following bits build just the dependencies of the project, without the source-code itself.
# This is so that we can take advantage of docker's caching and not rebuild everything all the damn time :P
WORKDIR /sms-irc
# add all the cargo files, to get deps
ADD ./Cargo.lock /sms-irc/
ADD ./Cargo.toml /sms-irc/
# make dummy src/lib.rs files, to satisfy cargo
RUN /bin/bash -c 'mkdir src; touch src/lib.rs';
# disable incremental compilation (never going to be used, and bloats binaries)
ENV CARGO_INCREMENTAL=0
# build all the dependencies
RUN ~/.cargo/bin/cargo build --release
# remove the dummy src/ lib.rs files
RUN /bin/bash -c 'rm -rf src'
# Now we a build the actual code...
# add the actual code
ADD ./src /sms-irc/src
# add migrations and other stuff
ADD ./migrations /sms-irc/migrations
# build it!
RUN ~/.cargo/bin/cargo build --release
FROM debian:stable-slim AS sms-irc
WORKDIR /sms-irc
RUN apt-get update && apt-get install -y libssl1.1 ca-certificates libpq5
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=sms-irc-compiled /sms-irc/target/release/sms-irc /sms-irc
ADD ./docker /sms-irc/docker
ENTRYPOINT "/sms-irc/sms-irc"