This repository has been archived by the owner on Dec 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
85 lines (76 loc) · 2.19 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
FROM alpine AS builder
RUN : && \
# dependencies for building
apk add --no-cache \
mariadb-dev \
openssl \
openssl-dev \
postgresql-dev \
sqlite-dev && \
: && \
echo -ne 'http://dl-cdn.alpinelinux.org/alpine/edge/main\n\
http://dl-cdn.alpinelinux.org/alpine/edge/community\n' \
>> "/etc/apk/repositories.edge" && \
apk add --no-cache \
--repositories-file "/etc/apk/repositories.edge" \
cargo \
rust && \
: && \
# central dependency storage for reuse
mkdir -p "/root/.cargo" && \
echo -ne '[build]\n\
target-dir = "/root/.cargo/target"\n' \
>> "/root/.cargo/config" && \
mkdir -p /tmp/blacklistd
RUN : && \
# diesel_cli for migration
cargo install \
diesel_cli \
--root /tmp/ \
--color never
COPY ./src /tmp/blacklistd/src
COPY ./Cargo.toml /tmp/blacklistd
# building blacklistd
WORKDIR /tmp/blacklistd
RUN cargo install \
--path /tmp/blacklistd \
--root /tmp/ \
--color never
FROM alpine
# transferring diesel_cli
COPY --from=builder /tmp/bin/diesel /usr/bin/
# transferring blacklistd
COPY --from=builder /tmp/bin/blacklistd /usr/bin
COPY ./migrations.mysql /usr/share/blacklistd/migrations.mysql
COPY ./migrations.postgres /usr/share/blacklistd/migrations.postgres
COPY ./migrations.sqlite /usr/share/blacklistd/migrations.sqlite
COPY ./LICENSE /usr/share/blacklistd/LICENSE
# transferring entrypoint and healtcheck
COPY ./docker/entrypoint.sh /usr/bin/entrypoint
COPY ./docker/healthcheck.sh /usr/bin/healthcheck
RUN : && \
# blacklistd dependencies
apk add --no-cache \
curl \
libgcc \
libpq \
mariadb-connector-c \
sqlite-libs && \
: && \
# user to execute blacklistd
addgroup blacklistd && \
adduser blacklistd \
-D -S -H \
-G blacklistd \
-s /bin/ash && \
mkdir -p /data && \
chown blacklistd:blacklistd \
/usr/share/blacklistd \
/data && \
chmod +x \
/usr/bin/entrypoint \
/usr/bin/healthcheck
WORKDIR /usr/share/blacklistd
USER blacklistd
CMD [ "/usr/bin/entrypoint" ]
HEALTHCHECK CMD [ "/usr/bin/healthcheck" ]