-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LAB-590] build backend container with private IPFS support (#700)
- Loading branch information
Showing
4 changed files
with
88 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,61 @@ | ||
FROM golang:1.20 as builder | ||
FROM golang:1.20-buster as builder | ||
|
||
# Install deps | ||
RUN apt-get update && apt-get install -y \ | ||
libssl-dev \ | ||
ca-certificates \ | ||
fuse | ||
|
||
COPY . /app/ | ||
RUN cd /app/ \ | ||
&& CGO_ENABLED=0 go build -o /go/bin/plex | ||
|
||
RUN apt-get update && apt-get -y install ca-certificates | ||
|
||
FROM alpine | ||
FROM busybox:1.31.1-glibc | ||
|
||
COPY --from=builder /go/bin/plex /plex | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY --from=builder /app/gateway/migrations /gateway/migrations | ||
|
||
# Copy custom IPFS binary with s3ds and healthcheck plugin | ||
COPY --from=quay.io/labdao/ipfs@sha256:461646b6ea97dffc86b1816380360be3d38d5a2c6c7c86352a2e3b0a5a4ccca5 /usr/local/bin/ipfs /usr/local/bin/ipfs | ||
|
||
# Copy init script from ipfs image | ||
COPY --from=quay.io/labdao/ipfs@sha256:461646b6ea97dffc86b1816380360be3d38d5a2c6c7c86352a2e3b0a5a4ccca5 /usr/local/bin/container_init_run /usr/local/bin/container_init_run | ||
|
||
# Copy container-init | ||
COPY docker/images/ipfs/container-init.d /container-init.d | ||
|
||
# init.d script IPFS runs before starting the daemon. Used to manipulate the IPFS config file. | ||
COPY docker/images/backend/docker-entrypoint.sh /docker-entrypoint.sh | ||
|
||
# Copy jq | ||
COPY --from=ghcr.io/jqlang/jq /jq /usr/local/bin/jq | ||
|
||
# This shared lib (part of glibc) doesn't seem to be included with busybox. | ||
COPY --from=builder /lib/*-linux-gnu*/libdl.so.2 /lib/ | ||
|
||
# Copy over SSL libraries. | ||
COPY --from=builder /usr/lib/*-linux-gnu*/libssl.so* /usr/lib/ | ||
COPY --from=builder /usr/lib/*-linux-gnu*/libcrypto.so* /usr/lib/ | ||
|
||
RUN chmod +x /docker-entrypoint.sh | ||
|
||
RUN mkdir -p /data/ipfs | ||
|
||
ENV POSTGRES_PASSWORD=MAKE_UP_SOMETHING_RANDOM | ||
ENV POSTGRES_USER=labdao | ||
ENV POSTGRES_DB=labdao | ||
ENV POSTGRES_HOST=localhost | ||
ENV FRONTEND_URL=http://localhost:3080 | ||
ENV BACALHAU_API_HOST=127.0.0.1 | ||
ENV IPFS_PATH=/data/ipfs | ||
ENV IPFS_PROFILE=server | ||
ENV BACALHAU_SERVE_IPFS_PATH=/data/ipfs | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["/plex"] | ||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
|
||
CMD ["web"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
repo="$IPFS_PATH" | ||
|
||
ipfs version | ||
|
||
if [ -e "$repo/config" ]; then | ||
echo "Found IPFS fs-repo at $repo" | ||
else | ||
ipfs init ${IPFS_PROFILE:+"--profile=$IPFS_PROFILE"} | ||
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 | ||
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 | ||
fi | ||
|
||
|
||
find /container-init.d -maxdepth 1 -type f -iname '*.sh' -print0 | sort -z | xargs -n 1 -0 -r container_init_run | ||
|
||
exec /plex "$@" |