Skip to content

Instantly share code, notes, and snippets.

@braydonf
Created January 10, 2022 20:47
Show Gist options
  • Save braydonf/f14471a85cf20aaa5fd826064eff78d1 to your computer and use it in GitHub Desktop.
Save braydonf/f14471a85cf20aaa5fd826064eff78d1 to your computer and use it in GitHub Desktop.
btcpayserver dockerfile with user
# This file is based on:
# https://github.com/btcpayserver/btcpayserver/blob/master/amd64.Dockerfile
#
# There are several changes made:
# - Change to fetch from remote git repository
# - Addition to run as btcpayserver user
FROM mcr.microsoft.com/dotnet/sdk:3.1.413-bullseye AS builder
RUN set -ex && \
apt-get update && \
apt-get install -qq gpg gpg-agent git
ENV BTCPAY_GIT_URL=https://github.com/btcpayserver/btcpayserver
ENV BTCPAY_GIT_TAG=v1.3.7
ENV BTCPAY_GIT_PATH=/tmp/btcpayserver/
ENV BTCPAY_USER_ID=1001
ENV BTCPAY_GROUP_ID=1001
COPY keys /tmp/keys
RUN gpg --import /tmp/keys/*
RUN mkdir -p $BTCPAY_GIT_PATH && \
cd $BTCPAY_GIT_PATH && \
git clone $BTCPAY_GIT_URL . && \
git checkout -b branch-${BTCPAY_GIT_TAG} $BTCPAY_GIT_TAG && \
git log -n 1 --show-signature && \
git verify-commit HEAD
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
WORKDIR /source
RUN git init --quiet . && \
git remote add origin ${BTCPAY_GIT_PATH}.git && \
git fetch --quiet
RUN git checkout origin/branch-${BTCPAY_GIT_TAG} -- nuget.config \
Build/Common.csproj \
BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj \
BTCPayServer/BTCPayServer.csproj \
BTCPayServer.Common/BTCPayServer.Common.csproj \
BTCPayServer.Rating/BTCPayServer.Rating.csproj \
BTCPayServer.Data/BTCPayServer.Data.csproj \
BTCPayServer.Client/BTCPayServer.Client.csproj
RUN cd BTCPayServer && dotnet restore
RUN git checkout origin/branch-$BTCPAY_GIT_TAG -- BTCPayServer.Common/. \
BTCPayServer.Rating/. \
BTCPayServer.Data/. \
BTCPayServer.Client/. \
BTCPayServer.Abstractions/. \
BTCPayServer/. \
Build/Version.csproj
RUN git add . && \
git config user.name "Docker Builder" && \
git config user.email "" && \
git commit -a -m "${BTCPAY_GIT_TAG}"
ARG CONFIGURATION_NAME=Release
RUN cd BTCPayServer && dotnet publish --output /app/ --configuration ${CONFIGURATION_NAME}
FROM mcr.microsoft.com/dotnet/aspnet:3.1.19-bullseye-slim
RUN groupadd -r btcpayserver --gid=${BTCPAY_GROUP_ID} && \
useradd -r -m -g btcpayserver --uid=${BTCPAY_USER_ID} btcpayserver && \
apt-get update && \
apt-get install -y --no-install-recommends iproute2 openssh-client gosu && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
RUN mkdir /datadir /app /home/btcpayserver/.btcpayserver && \
chown btcpayserver:btcpayserver /datadir /app /home/btcpayserver/.btcpayserver
WORKDIR /app
ENV BTCPAY_DATADIR=/datadir
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
VOLUME ["/datadir"]
COPY --from=builder --chown=btcpayserver:btcpayserver "/app" .
COPY docker-entrypoint.sh docker-entrypoint.sh
ENTRYPOINT ["/app/docker-entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment