Created reactor build script for docker images and tested local registry
parent
247ba5fdbc
commit
b52f243605
@ -1,8 +1,10 @@
|
|||||||
*
|
*
|
||||||
# exluding everything and only allowing directly relevant stuff
|
# exluding everything and only allowing directly relevant stuff
|
||||||
!cmd/server/main.go
|
!cmd/server/main.go
|
||||||
|
!cmd/reactor/main.go
|
||||||
!internal
|
!internal
|
||||||
!tokens
|
!tokens
|
||||||
!go.mod
|
!go.mod
|
||||||
!go.sum
|
!go.sum
|
||||||
!server
|
!server
|
||||||
|
!reactor
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM --platform=$BUILDPLATFORM golang:1.18-alpine as builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
ARG TARGETOS TARGETARCH TARGETVARIANT
|
||||||
|
|
||||||
|
RUN if [[ $TARGETVARIANT == "v7" ]]; \
|
||||||
|
then \
|
||||||
|
export GOARM=7; \
|
||||||
|
fi; \
|
||||||
|
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /reactor ./cmd/reactor/main.go
|
||||||
|
|
||||||
|
FROM alpine
|
||||||
|
|
||||||
|
COPY --from=builder /reactor .
|
||||||
|
|
||||||
|
ENTRYPOINT [ "./reactor" ]
|
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
display_usage() {
|
||||||
|
echo "Usage: $0 reactor_type"
|
||||||
|
}
|
||||||
|
|
||||||
|
# checking for help options
|
||||||
|
if [[ $@ == "--help" || $@ == "-h" ]]
|
||||||
|
then
|
||||||
|
display_usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# checking that arguements are not empty
|
||||||
|
if [[ -z $1 ]]
|
||||||
|
then
|
||||||
|
echo "Type of reactor not specified!"
|
||||||
|
display_usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# checking for valid reactor types
|
||||||
|
if [[ $1 == "pi" ]]
|
||||||
|
then
|
||||||
|
platform="linux/arm64"
|
||||||
|
elif [[ $1 == "bb" ]]
|
||||||
|
then
|
||||||
|
platform="linux/arm/v7"
|
||||||
|
else
|
||||||
|
echo "Reactor type $1 not supported!"
|
||||||
|
echo "Supported reactors include: pi, bb"
|
||||||
|
display_usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# building reactor image
|
||||||
|
|
||||||
|
echo "Building Reactor image for $1 platform=$platform"
|
||||||
|
|
||||||
|
docker buildx build --rm --platform=$platform -f Dockerfile.reactor --tag localhost:5000/reactor .
|
||||||
|
|
||||||
|
echo "Cleaning local images"
|
||||||
|
|
||||||
|
docker image remove localhost:5000/reactor
|
Loading…
Reference in New Issue