Skip to content

Commit 3744e91

Browse files
authored
[LAB-590] build backend container with private IPFS support (#700)
1 parent 46bb1e5 commit 3744e91

File tree

4 files changed

+88
-15
lines changed

4 files changed

+88
-15
lines changed

.github/workflows/ci.yml

+24-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ jobs:
2525
go:
2626
strategy:
2727
matrix:
28-
os: [ubuntu-22.04] # , macos-13]
28+
os:
29+
- ubuntu-22.04
30+
# - macos-13
2931
runs-on: ${{ matrix.os }}
3032
environment: ci
3133
steps:
@@ -77,7 +79,9 @@ jobs:
7779
ci-setup-ipfs:
7880
strategy:
7981
matrix:
80-
os: [ubuntu-22.04] # , macos-13]
82+
os:
83+
- ubuntu-22.04
84+
# - macos-13
8185
runs-on: ${{ matrix.os }}
8286
environment: ci
8387
steps:
@@ -102,8 +106,12 @@ jobs:
102106
ci-setup-bacalhau:
103107
strategy:
104108
matrix:
105-
os: [ubuntu-22.04]
106-
bacalhau_version: [1.0.3, 1.1.0]
109+
os:
110+
- ubuntu-22.04
111+
# - macos-13
112+
bacalhau_version:
113+
- 1.0.3
114+
- 1.1.0
107115
runs-on: ${{ matrix.os }}
108116
environment: ci
109117
steps:
@@ -130,8 +138,12 @@ jobs:
130138
- ci-setup-bacalhau
131139
strategy:
132140
matrix:
133-
os: [ubuntu-22.04] # , macos-13]
134-
bacalhau_version: [1.0.3, 1.1.0]
141+
os:
142+
- ubuntu-22.04
143+
# - macos-13
144+
bacalhau_version:
145+
- 1.0.3
146+
- 1.1.0
135147
runs-on: ${{ matrix.os }}
136148
environment: ci
137149
env:
@@ -263,8 +275,12 @@ jobs:
263275
- ci-setup-bacalhau
264276
strategy:
265277
matrix:
266-
os: [ubuntu-22.04] # , macos-13]
267-
bacalhau_version: [1.0.3, 1.1.0]
278+
os:
279+
- ubuntu-22.04
280+
# - macos-13
281+
bacalhau_version:
282+
- 1.0.3
283+
- 1.1.0
268284
runs-on: ${{ matrix.os }}
269285
environment: ci
270286
env:

Dockerfile

+39-3
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,61 @@
1-
FROM golang:1.20 as builder
1+
FROM golang:1.20-buster as builder
22

3+
# Install deps
4+
RUN apt-get update && apt-get install -y \
5+
libssl-dev \
6+
ca-certificates \
7+
fuse
8+
39
COPY . /app/
410
RUN cd /app/ \
511
&& CGO_ENABLED=0 go build -o /go/bin/plex
612

713
RUN apt-get update && apt-get -y install ca-certificates
814

9-
FROM alpine
15+
FROM busybox:1.31.1-glibc
1016

1117
COPY --from=builder /go/bin/plex /plex
1218
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
1319
COPY --from=builder /app/gateway/migrations /gateway/migrations
1420

21+
# Copy custom IPFS binary with s3ds and healthcheck plugin
22+
COPY --from=quay.io/labdao/ipfs@sha256:461646b6ea97dffc86b1816380360be3d38d5a2c6c7c86352a2e3b0a5a4ccca5 /usr/local/bin/ipfs /usr/local/bin/ipfs
23+
24+
# Copy init script from ipfs image
25+
COPY --from=quay.io/labdao/ipfs@sha256:461646b6ea97dffc86b1816380360be3d38d5a2c6c7c86352a2e3b0a5a4ccca5 /usr/local/bin/container_init_run /usr/local/bin/container_init_run
26+
27+
# Copy container-init
28+
COPY docker/images/ipfs/container-init.d /container-init.d
29+
30+
# init.d script IPFS runs before starting the daemon. Used to manipulate the IPFS config file.
31+
COPY docker/images/backend/docker-entrypoint.sh /docker-entrypoint.sh
32+
33+
# Copy jq
34+
COPY --from=ghcr.io/jqlang/jq /jq /usr/local/bin/jq
35+
36+
# This shared lib (part of glibc) doesn't seem to be included with busybox.
37+
COPY --from=builder /lib/*-linux-gnu*/libdl.so.2 /lib/
38+
39+
# Copy over SSL libraries.
40+
COPY --from=builder /usr/lib/*-linux-gnu*/libssl.so* /usr/lib/
41+
COPY --from=builder /usr/lib/*-linux-gnu*/libcrypto.so* /usr/lib/
42+
43+
RUN chmod +x /docker-entrypoint.sh
44+
45+
RUN mkdir -p /data/ipfs
46+
1547
ENV POSTGRES_PASSWORD=MAKE_UP_SOMETHING_RANDOM
1648
ENV POSTGRES_USER=labdao
1749
ENV POSTGRES_DB=labdao
1850
ENV POSTGRES_HOST=localhost
1951
ENV FRONTEND_URL=http://localhost:3080
52+
ENV BACALHAU_API_HOST=127.0.0.1
53+
ENV IPFS_PATH=/data/ipfs
54+
ENV IPFS_PROFILE=server
55+
ENV BACALHAU_SERVE_IPFS_PATH=/data/ipfs
2056

2157
EXPOSE 8080
2258

23-
ENTRYPOINT ["/plex"]
59+
ENTRYPOINT ["/docker-entrypoint.sh"]
2460

2561
CMD ["web"]

docker-compose.private.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ services:
2424

2525
backend:
2626
environment:
27-
IPFS_PATH: "/data/ipfs"
28-
BACALHAU_SERVE_IPFS_PATH: "/data/ipfs"
2927
BACALHAU_IPFS_SWARM_ADDRESSES: "/dns4/ipfs/tcp/4001/p2p/12D3KooWLpoHJCGxxKozRaUK1e1m2ocyVPB9dzbsU2cydujYBCD7"
30-
volumes:
31-
- ./docker/ipfs_data:/data/ipfs/
28+
IPFS_S3_ENABLED: "false"
29+
IPFS_SWARM_KEY_BASE64: "L2tleS9zd2FybS9wc2svMS4wLjAvCi9iYXNlMTYvCjk0Y2Y4ODFiMDZmZDI5YTgxNDVlMmY2MjNiMmRjNGMwNTU2Y2QxNTIwNWM4YjhjMzg0YWEzOThkY2U4YWFhMzYK"
30+
PRIVATE_IPFS: "true"
31+
LIBP2P_FORCE_PNET: "1"
32+
IPFS_DEBUG: "true"
33+
IPFS_LOGGING: "debug"
3234

3335
volumes:
3436
privateipfs:
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
set -e
3+
4+
repo="$IPFS_PATH"
5+
6+
ipfs version
7+
8+
if [ -e "$repo/config" ]; then
9+
echo "Found IPFS fs-repo at $repo"
10+
else
11+
ipfs init ${IPFS_PROFILE:+"--profile=$IPFS_PROFILE"}
12+
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
13+
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
14+
fi
15+
16+
17+
find /container-init.d -maxdepth 1 -type f -iname '*.sh' -print0 | sort -z | xargs -n 1 -0 -r container_init_run
18+
19+
exec /plex "$@"

0 commit comments

Comments
 (0)