Skip to content

Commit 62a9441

Browse files
authored
Merge pull request #2666 from bitshares/update-build-docker
Update Dockerfile and build-docker workflow
2 parents 61d3fb0 + cdc03c7 commit 62a9441

File tree

3 files changed

+71
-19
lines changed

3 files changed

+71
-19
lines changed

.github/workflows/build-docker.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ jobs:
1717
fi
1818
echo "DOCKER_PUSH_TAG=${DOCKER_PUSH_TAG}"
1919
echo "DOCKER_PUSH_TAG=${DOCKER_PUSH_TAG}" >> $GITHUB_ENV
20+
VERSION_MAJOR=`echo "${DOCKER_PUSH_TAG}" | cut -f1 -d'.'`
21+
if [ "${VERSION_MAJOR}" != "${DOCKER_PUSH_TAG}" ]; then
22+
VERSION_MINOR=`echo "${DOCKER_PUSH_TAG}" | cut -f2 -d'.'`
23+
DOCKER_PUSH_TAG_SHORT=${VERSION_MAJOR}.${VERSION_MINOR}
24+
if [ "${DOCKER_PUSH_TAG_SHORT}" != "${DOCKER_PUSH_TAG}" ]; then
25+
echo "DOCKER_PUSH_TAG_SHORT=${DOCKER_PUSH_TAG_SHORT}"
26+
echo "DOCKER_PUSH_TAG_SHORT=${DOCKER_PUSH_TAG_SHORT}" >> $GITHUB_ENV
27+
fi
28+
fi
2029
- name: Test tag
2130
if: env.DOCKER_PUSH_TAG != ''
2231
run: echo "${DOCKER_PUSH_TAG}"
@@ -35,10 +44,19 @@ jobs:
3544
with:
3645
username: ${{ secrets.DOCKERHUB_USERNAME }}
3746
password: ${{ secrets.DOCKERHUB_TOKEN }}
38-
- name: Push to DockerHub
39-
if: env.DOCKER_PUSH_TAG != ''
47+
- name: Push to DockerHub (for branches)
48+
if: env.DOCKER_PUSH_TAG != '' && env.DOCKER_PUSH_TAG_SHORT == ''
49+
uses: docker/build-push-action@v3
50+
with:
51+
context: .
52+
push: true
53+
tags: ${{ secrets.DOCKERHUB_REPO_PATH }}:${{ env.DOCKER_PUSH_TAG }}
54+
- name: Push to DockerHub (for tags)
55+
if: env.DOCKER_PUSH_TAG != '' && env.DOCKER_PUSH_TAG_SHORT != ''
4056
uses: docker/build-push-action@v3
4157
with:
4258
context: .
4359
push: true
44-
tags: bitshares/bitshares-core:${{ env.DOCKER_PUSH_TAG }}
60+
tags: |
61+
${{ secrets.DOCKERHUB_REPO_PATH }}:${{ env.DOCKER_PUSH_TAG }}
62+
${{ secrets.DOCKERHUB_REPO_PATH }}:${{ env.DOCKER_PUSH_TAG_SHORT }}

Dockerfile

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
FROM phusion/baseimage:focal-1.2.0
2-
MAINTAINER The bitshares decentralized organisation
3-
1+
# The image for building
2+
FROM phusion/baseimage:focal-1.2.0 as build
43
ENV LANG=en_US.UTF-8
4+
5+
# Install dependencies
56
RUN \
67
apt-get update && \
78
apt-get upgrade -y -o Dpkg::Options::="--force-confold" && \
@@ -29,7 +30,6 @@ RUN \
2930
libtool \
3031
doxygen \
3132
ca-certificates \
32-
fish \
3333
&& \
3434
apt-get clean && \
3535
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@@ -52,20 +52,50 @@ RUN \
5252
-DGRAPHENE_DISABLE_UNITY_BUILD=ON \
5353
. && \
5454
make witness_node cli_wallet get_dev_key && \
55-
install -s programs/witness_node/witness_node programs/genesis_util/get_dev_key programs/cli_wallet/cli_wallet /usr/local/bin && \
55+
install -s programs/witness_node/witness_node \
56+
programs/genesis_util/get_dev_key \
57+
programs/cli_wallet/cli_wallet \
58+
/usr/local/bin && \
5659
#
5760
# Obtain version
5861
mkdir -p /etc/bitshares && \
5962
git rev-parse --short HEAD > /etc/bitshares/version && \
6063
cd / && \
6164
rm -rf /bitshares-core
6265

63-
# Home directory $HOME
66+
# The final image
67+
FROM phusion/baseimage:focal-1.2.0
68+
LABEL maintainer="The bitshares decentralized organisation"
69+
ENV LANG=en_US.UTF-8
70+
71+
# Install required libraries
72+
RUN \
73+
apt-get update && \
74+
apt-get upgrade -y -o Dpkg::Options::="--force-confold" && \
75+
apt-get update && \
76+
apt-get install --no-install-recommends -y \
77+
libcurl4 \
78+
ca-certificates \
79+
&& \
80+
mkdir -p /etc/bitshares && \
81+
apt-get clean && \
82+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
83+
84+
COPY --from=build /usr/local/bin/* /usr/local/bin/
85+
COPY --from=build /etc/bitshares/version /etc/bitshares/
86+
6487
WORKDIR /
65-
RUN useradd -s /bin/bash -m -d /var/lib/bitshares bitshares
88+
RUN groupadd -g 10001 bitshares
89+
RUN useradd -u 10000 -g bitshares -s /bin/bash -m -d /var/lib/bitshares --no-log-init bitshares
6690
ENV HOME /var/lib/bitshares
6791
RUN chown bitshares:bitshares -R /var/lib/bitshares
6892

93+
# default exec/config files
94+
ADD docker/default_config.ini /etc/bitshares/config.ini
95+
ADD docker/default_logging.ini /etc/bitshares/logging.ini
96+
ADD docker/bitsharesentry.sh /usr/local/bin/bitsharesentry.sh
97+
RUN chmod a+x /usr/local/bin/bitsharesentry.sh
98+
6999
# Volume
70100
VOLUME ["/var/lib/bitshares", "/etc/bitshares"]
71101

@@ -74,14 +104,11 @@ EXPOSE 8090
74104
# p2p service:
75105
EXPOSE 1776
76106

77-
# default exec/config files
78-
ADD docker/default_config.ini /etc/bitshares/config.ini
79-
ADD docker/default_logging.ini /etc/bitshares/logging.ini
80-
ADD docker/bitsharesentry.sh /usr/local/bin/bitsharesentry.sh
81-
RUN chmod a+x /usr/local/bin/bitsharesentry.sh
82-
83107
# Make Docker send SIGINT instead of SIGTERM to the daemon
84108
STOPSIGNAL SIGINT
85109

110+
# Temporarily commented out due to permission issues caused by older versions, to be restored in a future version
111+
#USER bitshares:bitshares
112+
86113
# default execute entry
87-
CMD ["/usr/local/bin/bitsharesentry.sh"]
114+
ENTRYPOINT ["/usr/local/bin/bitsharesentry.sh"]

docker/bitsharesentry.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,17 @@ fi
8484
ln -f -s /etc/bitshares/config.ini /var/lib/bitshares
8585
ln -f -s /etc/bitshares/logging.ini /var/lib/bitshares
8686

87+
chown -R bitshares:bitshares /var/lib/bitshares
88+
89+
# Get the latest security updates
90+
apt-get update && apt-get upgrade -y -o Dpkg::Options::="--force-confold"
91+
8792
# Plugins need to be provided in a space-separated list, which
8893
# makes it necessary to write it like this
8994
if [[ ! -z "$BITSHARESD_PLUGINS" ]]; then
90-
exec "$BITSHARESD" --data-dir "${HOME}" ${ARGS} ${BITSHARESD_ARGS} --plugins "${BITSHARESD_PLUGINS}"
95+
exec /usr/bin/setpriv --reuid=bitshares --regid=bitshares --clear-groups \
96+
"$BITSHARESD" --data-dir "${HOME}" ${ARGS} ${BITSHARESD_ARGS} --plugins "${BITSHARESD_PLUGINS}"
9197
else
92-
exec "$BITSHARESD" --data-dir "${HOME}" ${ARGS} ${BITSHARESD_ARGS}
98+
exec /usr/bin/setpriv --reuid=bitshares --regid=bitshares --clear-groups \
99+
"$BITSHARESD" --data-dir "${HOME}" ${ARGS} ${BITSHARESD_ARGS}
93100
fi

0 commit comments

Comments
 (0)