FROM alpine:3.15 as intermediate

RUN mkdir /src
WORKDIR /src

# Install the build tools
RUN apk add git go make

# Fetch the Nebula source
RUN git clone https://github.com/slackhq/nebula.git

# Compile the Nebula GNU/Linux binaries for all platforms
WORKDIR /src/nebula
RUN make bin

RUN go get github.com/chrislusf/seaweedfs/weed

# Start from a clean image
FROM alpine:3.15

RUN mkdir /app
WORKDIR /app

# Copy over the compiled binaries
COPY --from=intermediate /src/nebula/nebula ./
COPY --from=intermediate /src/nebula/nebula-cert ./
COPY --from=intermediate /root/go/bin/weed ./

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" ]