-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile
96 lines (72 loc) · 3.38 KB
/
Containerfile
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
FROM docker.io/debian:stable-slim as build
ARG BTCD_VERSION="${BTCD_VERSION:-0.24.2}"
# Set time zone
ENV TZ="UTC"
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo ${TZ} > /etc/timezone
# Install packages required in build stage
RUN apt update && \
apt install -y --no-install-recommends \
ca-certificates \
curl \
gnupg \
tar
# Create directories for upstream source files
RUN install --directory --owner=root --group=root --mode=0755 /usr/local/src/btcd
# Download btcd archive
RUN curl --proto '=https' --tlsv1.2 \
--location https://github.com/btcsuite/btcd/releases/download/v${BTCD_VERSION}/btcd-linux-amd64-v${BTCD_VERSION}.tar.gz \
--output /usr/local/src/btcd/btcd-linux-amd64-v${BTCD_VERSION}.tar.gz
# Download btcd checksum
RUN curl --proto '=https' --tlsv1.2 \
--location https://github.com/btcsuite/btcd/releases/download/v${BTCD_VERSION}/manifest-v${BTCD_VERSION}.txt \
--output /usr/local/src/btcd/manifest-v${BTCD_VERSION}.txt
# Download btcd signature
RUN curl --proto '=https' --tlsv1.2 \
--location https://github.com/btcsuite/btcd/releases/download/v${BTCD_VERSION}/manifest-v${BTCD_VERSION}.sig \
--output /usr/local/src/btcd/manifest-v${BTCD_VERSION}.sig
# Add keys to GPG keyring
# https://github.com/lightningnetwork/lnd/blob/master/scripts/keys
COPY --chown=root:root gpg /root/gpg
RUN gpg --no-default-keyring --keyring /root/keyring.gpg --fingerprint
RUN for key in /root/gpg/*; do \
gpg --no-default-keyring --keyring /root/keyring.gpg --batch --import ${key}; \
done
# Verify checksum signature
RUN gpg --no-default-keyring --keyring /root/keyring.gpg --verify /usr/local/src/btcd/manifest-v${BTCD_VERSION}.sig /usr/local/src/btcd/manifest-v${BTCD_VERSION}.txt
# Verify btcd checksum
WORKDIR /usr/local/src/btcd
RUN sha256sum --ignore-missing --check manifest-v${BTCD_VERSION}.txt
# Unarchive btcd tarball
RUN tar --extract --gzip --file=/usr/local/src/btcd/btcd-linux-amd64-v${BTCD_VERSION}.tar.gz --directory=/usr/local/src/btcd
# Move binaries
RUN mv /usr/local/src/btcd/btcd-linux-amd64-v${BTCD_VERSION}/btcd /usr/local/bin/btcd && \
mv /usr/local/src/btcd/btcd-linux-amd64-v${BTCD_VERSION}/btcctl /usr/local/bin/btcctl
# Ensure binaries are executable
RUN chmod 0755 /usr/local/bin/btcd \
/usr/local/bin/btcctl
#---------------------------------------------------------------------
FROM docker.io/debian:stable-slim as main
# Set time zone
ENV TZ="UTC"
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo ${TZ} > /etc/timezone
# Install packages required in main stage
RUN apt update && \
apt install -y --no-install-recommends \
procps
# Copy binary from build stage
COPY --from=build --chown=root:root /usr/local/bin/btcd /usr/local/bin/btcd
COPY --from=build --chown=root:root /usr/local/bin/btcctl /usr/local/bin/btcctl
# Create btcd group and user
RUN groupadd --gid 10000 btcd && \
useradd --comment 'btcd' --create-home --gid 10000 --password '!' --shell '/bin/bash' --uid 10000 btcd
# Create directories for variable data
RUN install --directory --owner=btcd --group=btcd --mode=0750 /home/btcd/.btcd
# Create symlink for dummy 'sample-btcd.conf' configuration file
RUN ln -snf /dev/null /usr/local/bin/sample-btcd.conf
# Copy cmd.sh
COPY --chown=root:root cmd.sh /
RUN chmod 0755 /cmd.sh
USER btcd
CMD ["/bin/bash", "/cmd.sh"]