Build-in SeaweedFS support

This commit is contained in:
Scott Wallace 2022-04-02 17:09:06 +01:00
parent f288e97760
commit 71034fbc7f
Signed by: scott
GPG key ID: AA742FDC5AFE2A72
6 changed files with 73 additions and 36 deletions

View file

@ -1,4 +1,4 @@
FROM alpine:3.14 as intermediate
FROM alpine:3.15 as intermediate
RUN mkdir /src
WORKDIR /src
@ -6,27 +6,31 @@ WORKDIR /src
# Install the build tools
RUN apk add git go make
# Fetch the source
# Fetch the Nebula source
RUN git clone https://github.com/slackhq/nebula.git
# Compile the Linux binaries for all platforms
# Compile the Nebula GNU/Linux binaries for all platforms
WORKDIR /src/nebula
RUN echo 'bin-linux: $(ALL_LINUX:%=build/%/nebula) $(ALL_LINUX:%=build/%/nebula-cert)' >> Makefile
RUN make bin-linux
RUN make bin
RUN go get github.com/chrislusf/seaweedfs/weed
# Start from a clean image
FROM alpine:3.14
FROM alpine:3.15
RUN mkdir /app
WORKDIR /app
# Copy over the compiled binaries
COPY --from=intermediate /src/nebula/build ./
COPY --from=intermediate /src/nebula/nebula ./
COPY --from=intermediate /src/nebula/nebula-cert ./
COPY --from=intermediate /root/go/bin/weed ./
# Rename the directories from `go env` format to `uname` format
RUN mv linux-amd64 linux-x86_64
COPY docker-entrypoint.sh entrypoint.sh
COPY nebula-start.sh ./
COPY seaweedfs-start.sh ./
COPY docker-entrypoint.sh ./entrypoint.sh
EXPOSE 4242/udp
EXPOSE 9333/tcp
EXPOSE 8080/tcp
ENTRYPOINT [ "/bin/sh", "/app/entrypoint.sh" ]

View file

@ -6,13 +6,14 @@ services:
image: dcr.wallace.sh/scott/infranet:latest
volumes:
- /path/to/infranet/config:/etc/nebula
- /path/to/infranet/filestore:/storage
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
environment:
- TZ=Europe/London
# A Lighthouse should be listening for incoming connections; but not nodes
# ports:
# - 4242:4242/udp
- TZ=UTC
- LIGHTHOUSE=true
ports:
- 4242:4242/udp
restart: unless-stopped

17
docker-compose-node.yaml Normal file
View file

@ -0,0 +1,17 @@
---
version: "3"
services:
infranet:
container_name: infranet
image: dcr.wallace.sh/scott/infranet:latest
volumes:
- /path/to/infranet/config:/etc/nebula
- /path/to/infranet/filestore:/storage
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
environment:
- TZ=UTC
- LIGHTHOUSE=false
restart: unless-stopped

View file

@ -1,24 +1,6 @@
#!/bin/sh
ARCH=$(uname -m)
BIN_DIR=/app/linux-${ARCH}
DATA_DIR=/etc/nebula
set -e
# Build host certs if they don't exist
if ! test -f ${DATA_DIR}/host.crt; then
cd ${DATA_DIR} || exit 1
# Generate a CSR if it doesn't already exist
if ! test -d ${DATA_DIR}/host.csr; then
"${BIN_DIR}/nebula-cert" keygen -out-key host.key -out-pub host.csr
# shellcheck disable=SC2016
echo 'You will need to get the `host.csr` file signed by a cluster admin'
exit 3
else
# shellcheck disable=SC2016
echo 'Awaiting for `host.csr` to be signed by a cluster admin'
exit 4
fi
fi
# Run the platform-specific binary
"${BIN_DIR}/nebula" -config ${DATA_DIR}/config.yaml
/app/nebula-start.sh
/app/seaweedfs-start.sh

23
nebula-start.sh Normal file
View file

@ -0,0 +1,23 @@
#!/bin/sh
BIN_DIR=/app
DATA_DIR=/etc/nebula
# Build host certs if they don't exist
if ! test -f ${DATA_DIR}/host.crt; then
cd ${DATA_DIR} || exit 1
# Generate a CSR if it doesn't already exist
if ! test -d ${DATA_DIR}/host.csr; then
"${BIN_DIR}/nebula-cert" keygen -out-key host.key -out-pub host.csr
# shellcheck disable=SC2016
echo 'You will need to get the `host.csr` file signed by a cluster admin'
exit 3
else
# shellcheck disable=SC2016
echo 'Awaiting for `host.csr` to be signed by a cluster admin'
exit 4
fi
fi
# Run the platform-specific binary
"${BIN_DIR}/nebula" -config ${DATA_DIR}/config.yaml

10
seaweedfs-start.sh Normal file
View file

@ -0,0 +1,10 @@
#!/bin/sh
NEBULA_IP=$(ip -f inet addr show nebula1 | awk '/inet / {print $2}' | cut -f1 -d'/')
SEAWEEDFS_MASTERS=10.10.100.1:9333 # Need an odd number #,10.10.100.21:9333
if test "${LIGHTHOUSE}" == "true"; then
weed master -ip="${NEBULA_IP}" -port=9333 -mdir=/storage -peers=${SEAWEEDFS_MASTERS}
else
weed volume -dir=/storage -port=8080 -mserver=${SEAWEEDFS_MASTERS}
fi