Dockerfile: add production docker image

We add a new standalone Dockerfile that checks out the code from GitHub
and goes through all necessary build steps from scratch. The git commit
or tag that should be checked out before building can be specified as a
build argument.
To still allow more rapid development, the old Dockerfile that builds
from the local source is renamed to dev.Dockerfile to make the
distinction clear.
This commit is contained in:
Oliver Gugger 2020-11-25 15:28:51 +01:00
parent d18397fe2b
commit 64d53f700e
No known key found for this signature in database
GPG key ID: 8E4256593F177720
2 changed files with 76 additions and 9 deletions

View file

@ -1,17 +1,24 @@
FROM golang:1.15.5-alpine as builder
# Copy in the local repository to build from.
COPY . /go/src/github.com/lightninglabs/lightning-terminal
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS
# queries required to connect to linked containers succeed.
ENV GODEBUG netdns=cgo
# Pass a tag, branch or a commit using build-arg. This allows a docker image to
# be built from a specified Git state. The default image will use the Git tip of
# master by default.
ARG checkout="master"
# Explicitly turn on the use of modules (until this becomes the default).
ENV GO111MODULE on
ENV NODE_VERSION=v12.17.0
# We need some additional proto files with google annotations, the version
# should match what's in lnd's scripts/install_travis_proto.sh
ENV PROTOC_VERSION=3.4.0
ENV PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip"
# Install dependencies and install/build lightning-terminal.
RUN apk add --no-cache --update alpine-sdk \
git \
@ -21,18 +28,21 @@ RUN apk add --no-cache --update alpine-sdk \
binutils \
tar \
protobuf-dev \
zip \
&& curl -sfSLO ${PROTOC_URL} \
&& unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /usr/local \
&& rm /usr/local/bin/protoc /usr/local/readme.txt \
&& touch ~/.bashrc \
&& curl -sfSLO https://unofficial-builds.nodejs.org/download/release/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64-musl.tar.xz \
&& tar -xf node-${NODE_VERSION}-linux-x64-musl.tar.xz -C /usr --strip 1 \
&& rm node-${NODE_VERSION}-linux-x64-musl.tar.xz \
&& curl -o- -L https://yarnpkg.com/install.sh | bash \
&& . ~/.bashrc \
&& cd /go/src/github.com/lightninglabs/lightning-terminal \
&& make install \
&& go install -v -trimpath github.com/lightningnetwork/lnd/cmd/lncli \
&& go install -v -trimpath github.com/lightninglabs/faraday/cmd/frcli \
&& go install -v -trimpath github.com/lightninglabs/loop/cmd/loop \
&& go install -v -trimpath github.com/lightninglabs/pool/cmd/pool
&& git clone https://github.com/lightninglabs/lightning-terminal /go/src/github.com/lightninglabs/lightning-terminal \
&& cd /go/src/github.com/lightninglabs/lightning-terminal \
&& git checkout $checkout \
&& make install \
&& make go-install-cli
# Start a new, final image to reduce size.
FROM alpine as final

57
dev.Dockerfile Normal file
View file

@ -0,0 +1,57 @@
FROM golang:1.15.5-alpine as builder
# Copy in the local repository to build from.
COPY . /go/src/github.com/lightninglabs/lightning-terminal
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS
# queries required to connect to linked containers succeed.
ENV GODEBUG netdns=cgo
# Explicitly turn on the use of modules (until this becomes the default).
ENV GO111MODULE on
ENV NODE_VERSION=v12.17.0
# Install dependencies and install/build lightning-terminal.
RUN apk add --no-cache --update alpine-sdk \
git \
make \
curl \
bash \
binutils \
tar \
protobuf-dev \
&& touch ~/.bashrc \
&& curl -sfSLO https://unofficial-builds.nodejs.org/download/release/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64-musl.tar.xz \
&& tar -xf node-${NODE_VERSION}-linux-x64-musl.tar.xz -C /usr --strip 1 \
&& rm node-${NODE_VERSION}-linux-x64-musl.tar.xz \
&& curl -o- -L https://yarnpkg.com/install.sh | bash \
&& . ~/.bashrc \
&& cd /go/src/github.com/lightninglabs/lightning-terminal \
&& make install \
&& make go-install-cli
# Start a new, final image to reduce size.
FROM alpine as final
# Define a root volume for data persistence.
VOLUME /root/.lnd
# Expose lightning-terminal and lnd ports (server, rpc).
EXPOSE 8443 10009 9735
# Copy the binaries and entrypoint from the builder image.
COPY --from=builder /go/bin/litd /bin/
COPY --from=builder /go/bin/lncli /bin/
COPY --from=builder /go/bin/frcli /bin/
COPY --from=builder /go/bin/loop /bin/
COPY --from=builder /go/bin/pool /bin/
# Add bash.
RUN apk add --no-cache \
bash \
jq \
ca-certificates
# Specify the start command and entrypoint as the lightning-terminal daemon.
ENTRYPOINT ["litd"]