Generate SSH keys in the docker container

This commit is contained in:
nicolas.dorier 2019-09-20 17:23:32 +09:00
parent 3dada3c464
commit 6d703d590b
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
3 changed files with 13 additions and 2 deletions

View file

@ -16,7 +16,7 @@ RUN cd BTCPayServer && dotnet publish --output /app/ --configuration Release
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1.9-alpine3.7
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT false
RUN apk add --no-cache icu-libs
RUN apk add --no-cache icu-libs openssh-keygen
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8

View file

@ -20,7 +20,7 @@ RUN cd BTCPayServer && dotnet publish --output /app/ --configuration Release
# Force the builder machine to take make an arm runtime image. This is fine as long as the builder does not run any program
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1.9-stretch-slim-arm32v7
COPY --from=builder /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static
RUN apt-get update && apt-get install -y --no-install-recommends iproute2 \
RUN apt-get update && apt-get install -y --no-install-recommends iproute2 openssh-client \
&& rm -rf /var/lib/apt/lists/*
ENV LC_ALL en_US.UTF-8

View file

@ -1,4 +1,15 @@
#!/bin/sh
echo "$(/sbin/ip route|awk '/default/ { print $3 }') host.docker.internal" >> /etc/hosts
if ! [ -f "$BTCPAY_SSHKEYFILE" ]; then
echo "Creating BTCPay Server SSH key File..."
ssh-keygen -t rsa -f "$BTCPAY_SSHKEYFILE" -q -P "" -m PEM -C btcpayserver > /dev/null
fi
if [ -f "$BTCPAY_SSHAUTHORIZEDKEYS" ] && ! grep -q "btcpayserver$" "$BTCPAY_SSHAUTHORIZEDKEYS"; then
echo "Adding BTCPay Server SSH key to authorized keys"
cat "$BTCPAY_SSHKEYFILE.pub" >> "$BTCPAY_SSHAUTHORIZEDKEYS"
fi
exec dotnet BTCPayServer.dll