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
Show file tree
Hide file tree
Changes from all 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
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM golang:1.11-stretch
# Go base image
ARG base=golang:1.11-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 <lgierth@ipfs.io>

# There is a copy of this Dockerfile called Dockerfile.fast,
Expand All @@ -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 \
Expand All @@ -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 <lgierth@ipfs.io>

# Get the ipfs binary, entrypoint script, and TLS CAs from the build container.
Expand All @@ -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

# Swarm TCP; should be exposed to the public
EXPOSE 4001
Expand Down
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.11-stretch
# Go base image
ARG base=golang:1.11-stretch
FROM $base
FROM $base
MAINTAINER Lars Gierth <lgierth@ipfs.io>

# This is a copy of /Dockerfile,
Expand Down Expand Up @@ -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 \
Expand All @@ -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

Expand Down
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,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
```

When starting a container running ipfs for the first time with an empty data directory, it will call `ipfs init` to initialize configuration files and generate a new keypair. At this time, you can choose which profile to apply using the `IPFS_PROFILE` environment variable:

docker run -d --name ipfs_host -e IPFS_PROFILE=server -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/go-ipfs:latest
Expand Down