Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arm32 Dockerfile #5370

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add parameters to Dockerfiles
Allow, for example:

  $ docker -v build . -f Dockerfile.fast --build-arg base=arm32v7/golang:1.10-stretch --build-arg tini_executable=tini-armhf --build-arg 'busybox_base=arm32v7/busybox:1-glibc' --build-arg glibc_shared_lib_arch=arm-linux-gnueabihf

to build for a Raspberry Pi (arm32v7)

License: MIT
Signed-off-by: John Elliott <[email protected]>
johnelliott committed Sep 8, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit f07ac6c44ebc842ace13334ca97c1ec5d586f25a
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM golang:1.10-stretch
# Go base image
ARG base=golang:1.10-stretch
# Busybox base image
ARG busybox_base=busybox:1-glibc
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a docker expert, but shouldn't this just go down at line 46? Is there a reason to duplicate it?

FROM $base
MAINTAINER Lars Gierth <[email protected]>

# There is a copy of this Dockerfile called Dockerfile.fast,
@@ -22,6 +26,8 @@ RUN cd $SRC_DIR \
# Get su-exec, a very minimal tool for dropping privileges,
# and tini, a very minimal init daemon for containers
ENV SUEXEC_VERSION v0.2
# Tini executable filename
ARG tini_executable=tini
ENV TINI_VERSION v0.16.1
RUN set -x \
&& cd /tmp \
@@ -30,14 +36,16 @@ RUN set -x \
&& git checkout -q $SUEXEC_VERSION \
&& make \
&& cd /tmp \
&& wget -q -O tini https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini \
&& wget -q -O tini https://github.com/krallin/tini/releases/download/$TINI_VERSION/$tini_executable \
&& chmod +x tini

# Get the TLS CA certificates, they're not provided by busybox.
RUN apt-get update && apt-get install -y ca-certificates

# Now comes the actual target image, which aims to be as small as possible.
FROM busybox:1-glibc
ARG busybox_base
FROM ${busybox_base}
#FROM arm32v7/busybox:1-glibc
MAINTAINER Lars Gierth <[email protected]>

# Get the ipfs binary, entrypoint script, and TLS CAs from the build container.
@@ -49,7 +57,8 @@ COPY --from=0 /tmp/tini /sbin/tini
COPY --from=0 /etc/ssl/certs /etc/ssl/certs

# This shared lib (part of glibc) doesn't seem to be included with busybox.
COPY --from=0 /lib/x86_64-linux-gnu/libdl-2.24.so /lib/libdl.so.2
ARG glibc_shared_lib_arch=x86_64-linux-gnu
COPY --from=0 /lib/${glibc_shared_lib_arch}/libdl-2.24.so /lib/libdl.so.2

# Ports for Swarm TCP, Swarm uTP, API, Gateway, Swarm Websockets
EXPOSE 4001
9 changes: 7 additions & 2 deletions Dockerfile.fast
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM golang:1.10-stretch
# Go base image
ARG base=golang:1.10-stretch
FROM $base
FROM $base
MAINTAINER Lars Gierth <[email protected]>

# This is a copy of /Dockerfile,
@@ -34,6 +37,8 @@ RUN set -x \
# Get su-exec, a very minimal tool for dropping privileges,
# and tini, a very minimal init daemon for containers
ENV SUEXEC_VERSION v0.2
# Tini executable filename
ARG tini_executable=tini
ENV TINI_VERSION v0.16.1
RUN set -x \
&& cd /tmp \
@@ -42,7 +47,7 @@ RUN set -x \
&& git checkout -q $SUEXEC_VERSION \
&& make \
&& cd /tmp \
&& wget -q -O tini https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini \
&& wget -q -O tini https://github.com/krallin/tini/releases/download/$TINI_VERSION/$tini_executable \
&& chmod +x tini \
&& mv su-exec/su-exec tini /sbin/ # Install them

42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -315,6 +315,48 @@ Stop the running container:

docker stop ipfs_host

### Building Docker images
Copy link
Member

Choose a reason for hiding this comment

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

Should be updated for go 1.11.


For other platforms such as ARM, you may need to build a docker image to run.

The main Dockerfile takes the following args:
- `base`: The base go image for the target platform
- `busybox_base`: The busybox base image for the target platform
- `tini_executable`: The tini executable path for the target platform
- `glibc_shared_lib_arch`: The target platform shared lib for glibc supplementing busybox
Copy link
Member

Choose a reason for hiding this comment

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

Is there really no better way to do this (i.e., with one variable). From what I can tell, there simply isn't but I'm not a Docker expert so I'd like to double check.

Copy link
Author

Choose a reason for hiding this comment

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

Same here. This was seemingly the only way.


#### `base`
Possible values:
- `golang:1.10-stretch` (default)
- `arm32v7/golang:1.10-stretch`

#### `busybox_base`
Possible values:
- `busybox:1-glibc` (default)
- `arm32v7/golang:1.10-stretch`
Copy link
Member

Choose a reason for hiding this comment

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

busybox.


#### `tini_executable`
Possible values:
- `tini` (default)
- `tini-armhf`

#### `glibc_shared_lib_arch`
Possible values:
- `x86_64-linux-gnu` (default)
- `arm-linux-gnueabihf`

#### Example Docker image build

Building for x86 linux:
```sh
docker build . -f Dockerfile
```

Building for Raspberry Pi (arm32v7):
```sh
docker build . -f Dockerfile --build-arg base=arm32v7/golang:1.10-stretch --build-arg tini_executable=tini-armhf --build-arg 'busybox_base=arm32v7/busybox:1-glibc' --build-arg glibc_shared_lib_arch=arm-linux-gnueabihf
```

### Troubleshooting

If you have previously installed IPFS before and you are running into