-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
102 lines (82 loc) · 2.04 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
FROM rust:1.67 as planner
WORKDIR /app
RUN cargo install cargo-chef
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM rust:1.67 as cacher
WORKDIR /app
RUN cargo install cargo-chef
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
FROM rust:1.67 as builder
WORKDIR /app
COPY . .
ARG db
ENV DATABASE_URL=$db
COPY --from=cacher /app/target target
RUN cargo build --release --bin reseda-rust
FROM ubuntu:latest
# set version label
ARG WIREGUARD_RELEASE="v1.0.20210914"
RUN \
mkdir /app \
echo "**** install dependencies ****" && \
apt-get update && \
apt-get install -y --no-install-recommends \
libc6 \
sudo \
bc \
build-essential \
curl \
dkms \
git \
gnupg \
ifupdown \
iproute2 \
iptables \
iputils-ping \
jq \
libelf-dev \
net-tools \
openresolv \
perl \
pkg-config \
qrencode \
ca-certificates
RUN \
echo "**** install wireguard-tools ****" && \
if [ -z ${WIREGUARD_RELEASE+x} ]; then \
WIREGUARD_RELEASE=$(curl -sX GET "https://api.github.com/repos/WireGuard/wireguard-tools/tags" \
| jq -r .[0].name); \
fi && \
cd /app && \
GIT_SSL_NO_VERIFY=1 git clone https://git.zx2c4.com/wireguard-linux-compat && \
GIT_SSL_NO_VERIFY=1 git clone https://git.zx2c4.com/wireguard-tools && \
echo "**** finishing with ${WIREGUARD_RELEASE} update ****" && \
cd wireguard-tools && \
git checkout "${WIREGUARD_RELEASE}" && \
make -C src -j$(nproc) && \
make -C src install
RUN \
echo "**** clean up ****" && \
rm -rf \
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/*
COPY --from=builder /app/target/release/reseda-rust ./app
# ports and volumes
EXPOSE 8443/udp
EXPOSE 80
EXPOSE 443
ARG access_key
ARG db
RUN mkdir ./app/configuration
RUN echo "#!/bin/bash\n" \
" echo -e \"database_auth: '$db'\naccess_key: '$access_key'\" > ./app/configuration/base.yml\n" > script.sh
RUN chmod +x script.sh
RUN ./script.sh
WORKDIR /app
RUN sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
RUN mkdir ./configs
RUN sudo su - root
CMD ["sudo", "./reseda-rust"]