Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions 1.14.4/x86_64-bionic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:bionic

# To improve : static hash make dynamic build of versions impossible.
ARG VERSION=1.14.4
ARG VERSION_HASH=6266235abe4bcbd41ea57bdf42f11ef89aa69f0386e8c8846d5228af69e7fa13
ARG TARGETPLATFORM
Comment thread
patricklodder marked this conversation as resolved.
Outdated

ENV USER=dogecoin
ENV DATADIR=/${USER}/.dogecoin
Expand All @@ -19,23 +19,28 @@ RUN apt update && apt install -y \
wget \
&& rm -rf /var/lib/apt/lists/*

# Download Dogecoin Core from github releases.
# Download Dogecoin Core from github releases,
# manage binary architecture using buildx & TARGETPLATFORM.
WORKDIR /tmp

RUN set -ex && \
if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then TARGETPLATFORM=x86_64-linux-gnu; fi \
&& if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then TARGETPLATFORM=aarch64-linux-gnu; fi \
&& if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then TARGETPLATFORM=arm-linux-gnueabihf; fi \
&& if [ "${TARGETPLATFORM}" = "linux/386" ]; then TARGETPLATFORM=i686-pc-linux-gnu; fi \
&& wget https://github.com/dogecoin/dogecoin/releases/download/v${VERSION}/dogecoin-${VERSION}-${TARGETPLATFORM}.tar.gz

# Move downloaded binaries and man pages in the container system.
# Setuid on binaries with $USER rights, to limit root usage.
#
# Security: more secure way than check hash for download,
# see https://github.com/docker-library/official-images#security
RUN cd /tmp && \
wget https://github.com/dogecoin/dogecoin/releases/download/v${VERSION}/dogecoin-${VERSION}-x86_64-linux-gnu.tar.gz && \
echo "${VERSION_HASH} dogecoin-${VERSION}-x86_64-linux-gnu.tar.gz" | sha256sum -c && \
tar -xvf dogecoin-${VERSION}-x86_64-linux-gnu.tar.gz --strip-components=1 && \
# Setuid on binaries with $USER rights, to prevent
# root right with `docker exec`.
RUN tar -xvf dogecoin-${VERSION}-*.tar.gz --strip-components=1 && \
cp share/man/man1/*.1 /usr/share/man/man1 && \
cp bin/dogecoin* /usr/local/bin && \
chown ${USER}:${USER} /usr/local/bin/dogecoin* && \
chmod 4555 /usr/local/bin/dogecoin* && \
rm -rf /tmp/*

COPY docker-entrypoint.py /usr/local/bin/docker-entrypoint
COPY --chmod=500 docker-entrypoint.py /usr/local/bin/docker-entrypoint

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 12/17 : COPY --chmod=500 docker-entrypoint.py /usr/local/bin/docker-entrypoint
the --chmod option requires BuildKit. Refer to https://docs.docker.com/go/buildkit/ to learn how to build images with BuildKit enabled

Are we sure we want that dependency?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know chmod was specific to buildx. Depend on the previous question about buildx vs dpkg.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It requires buildkit, which is not enabled by default everywhere. I think we can use RUN chmod 500 too?

@AbcSxyZ AbcSxyZ Nov 24, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I would just recommend to use chmod within COPY if the image is only deployed/buildable with buildx. Otherwise, in RUN statement of course.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you recommend it? Reduction of build steps or is there more to it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduction of build steps

Yes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Could you please change that then? Let's keep the extra build step until buildkit is the default build process everywhere (currently it's only default on docker-desktop.)

@AbcSxyZ AbcSxyZ Nov 28, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rn, because we are using TARGETPLATFORM, someone who will build this Dockerfile will need buildx.

In any case not a big change, but don't you want to do this edit when/if we're having a solution to enable docker build command ?

If we want to go with docker build, I suppose we should use dpkg. I think it's a matter of choice between having a more concise Dockerfile using buildx solution, where people will use this image in their own Dockerfile or with the cli and won't build it manually. Or we can get something more verbose, possibly a dirtier mapping, but easily buildable with dpkg.

I like this idea of using docker build, the solution may be not that bad, but it's the "simpler" path here.
Let's continue in #17.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do docker build --build-arg TARGETPLATFORM=linux/amd64 . right now to build this but it will fail on this instruction if one doesn't use buildkit by default.

The reason why I am asking to make the separate RUN chmod 500 /usr/local/bin/docker-entrypoint for the time being is to retain some form of backward compatibility for now, until buildkit is the only supported method. Since this does not affect the outcome - it only costs a trivial build step - this de-optimization helps portability until a later time that the build system is based on buildkit everywhere...

I have no way to build this without buildkit for this issue, whereas for the first issue I mentioned there is a workaround.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's supersede this design with work from #17 :)


WORKDIR ${HOME}

Expand Down