Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate backend image #81

Merged
merged 11 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Dockerfile.add-frontend → Dockerfile.add-backend
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM gcr.io/spiffe-io/spire-server:1.1.3
RUN apk add curl
COPY bin/tornjak-agent tornjak-agent
COPY ui-agent ui-agent
COPY bin/tornjak-backend tornjak-backend
COPY sample-keys sample-keys


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM gcr.io/spiffe-io/spire-server:{version}
RUN apk add curl
COPY bin/tornjak-agent tornjak-agent
COPY ui-agent ui-agent
COPY bin/tornjak-backend tornjak-backend
COPY sample-keys sample-keys


Expand Down
File renamed without changes.
55 changes: 26 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
.PHONY: ui vendor build ui-agent ui-manager container-agent container-agent-push container-manager container-manager-push release-container-agent-multiversions push container-frontend-auth container-frontend-auth-push container-frontend-noauth container-frontend-noauth-push
.PHONY: ui vendor build ui-agent ui-manager container-spire-tornjak-be container-spire-tornjak-be-push container-manager container-manager-push release-container-agent-multiversions push container-frontend container-frontend-push

CONTAINER_TAG ?= tsidentity/tornjak-spire-server:latest
CONTAINER_TAG_FRONTEND ?= tsidentity/tornjak-fe:latest
CONTAINER_VERSION_IMAGEPATH ?= tsidentity/tornjak-spire-server
CONTAINER_VERSION_GHCR_IMAGEPATH ?= ghcr.io/spiffe/tornjak-spire-server
CONTAINER_BACKEND_TAG ?= tsidentity/spire-server-tornjak-be:latest
CONTAINER_FRONTEND_TAG ?= tsidentity/tornjak-fe:latest
CONTAINER_BACKEND_SPIRE_VERSION_IMAGEPATH ?= tsidentity/spire-server-tornjak-be
CONTAINER_BACKEND_SPIRE_VERSION_GHCR_IMAGEPATH ?= ghcr.io/spiffe/spire-server-tornjak-be
CONTAINER_FRONTEND_GHCR_IMAGEPATH ?= ghcr.io/spiffe/tornjak-fe
CONTAINER_MANAGER_TAG ?= tsidentity/tornjak-manager:latest
GO_FILES := $(shell find . -type f -name '*.go' -not -name '*_test.go' -not -path './vendor/*')
AUTH_SERVER_URI ?= http://localhost:8080
APP_SERVER_URI ?= http://localhost:10000

all: bin/tornjak-agent bin/tornjak-manager ui-agent ui-manager container-agent container-manager container-frontend-auth container-frontend-noauth
all: bin/tornjak-backend bin/tornjak-manager ui-manager container-spire-tornjak-be container-manager container-frontend

bin/tornjak-agent: $(GO_FILES) vendor
bin/tornjak-backend: $(GO_FILES) vendor
# Build hack because of flake of imported go module
docker run --rm -v "${PWD}":/usr/src/myapp -w /usr/src/myapp -e GOOS=linux -e GOARCH=amd64 golang:1.16 /bin/sh -c "go build --tags 'sqlite_json' tornjak-backend/cmd/agent/agent.go; go build --tags 'sqlite_json' -mod=vendor -ldflags '-s -w -linkmode external -extldflags "-static"' -o bin/tornjak-agent tornjak-backend/cmd/agent/agent.go"
docker run --rm -v "${PWD}":/usr/src/myapp -w /usr/src/myapp -e GOOS=linux -e GOARCH=amd64 golang:1.16 /bin/sh -c "go build --tags 'sqlite_json' tornjak-backend/cmd/agent/agent.go; go build --tags 'sqlite_json' -mod=vendor -ldflags '-s -w -linkmode external -extldflags "-static"' -o bin/tornjak-backend tornjak-backend/cmd/agent/agent.go"


bin/tornjak-manager: $(GO_FILES) vendor
Expand Down Expand Up @@ -41,39 +40,37 @@ vendor:
go mod tidy
go mod vendor

container-agent: bin/tornjak-agent ui-agent
docker build --no-cache -f Dockerfile.add-frontend -t ${CONTAINER_TAG} .
container-spire-tornjak-be: bin/tornjak-backend
docker build --no-cache -f Dockerfile.add-backend -t ${CONTAINER_BACKEND_TAG} .

container-agent-push: container-agent
docker push ${CONTAINER_TAG}
container-spire-tornjak-be-push: container-spire-tornjak-be
docker push ${CONTAINER_BACKEND_TAG}

container-manager: bin/tornjak-manager ui-manager
docker build --no-cache -f Dockerfile.tornjak-manager -t ${CONTAINER_MANAGER_TAG} .

container-manager-push: container-manager
docker push ${CONTAINER_MANAGER_TAG}

release-container-agent-multiversions: bin/tornjak-agent ui-agent
release-spire-tornjak-be-multiversions: bin/tornjak-backend
for i in $(shell cat SPIRE_BUILD_VERSIONS); do \
./build-and-push-versioned-container.sh $$i ${CONTAINER_VERSION_IMAGEPATH}; \
./build-and-push-versioned-container.sh $$i ${CONTAINER_BACKEND_SPIRE_VERSION_IMAGEPATH}; \
done

release-container-agent-multiversions-ghcr: bin/tornjak-agent ui-agent
release-spire-tornjak-be-multiversions-ghcr: bin/tornjak-backend
for i in $(shell cat SPIRE_BUILD_VERSIONS); do \
./build-and-push-versioned-container.sh $$i ${CONTAINER_VERSION_GHCR_IMAGEPATH}; \
./build-and-push-versioned-container.sh $$i ${CONTAINER_BACKEND_SPIRE_VERSION_GHCR_IMAGEPATH}; \
done

container-frontend-auth:
docker build --no-cache -f Dockerfile.add-frontend-auth -t ${CONTAINER_TAG_FRONTEND} --build-arg REACT_APP_API_SERVER_URI=${APP_SERVER_URI} --build-arg REACT_APP_AUTH_SERVER_URI=${AUTH_SERVER_URI} .
container-frontend:
docker build --no-cache -f Dockerfile.frontend-container -t ${CONTAINER_FRONTEND_TAG} .

container-frontend-auth-push: container-frontend-auth
docker push ${CONTAINER_TAG_FRONTEND}
container-frontend-push: container-frontend
docker push ${CONTAINER_FRONTEND_TAG}

container-frontend-noauth:
docker build --no-cache -f Dockerfile.add-frontend-auth -t ${CONTAINER_TAG_FRONTEND} --build-arg REACT_APP_API_SERVER_URI=${APP_SERVER_URI} .

container-frontend-noauth-push: container-frontend-noauth
docker push ${CONTAINER_TAG_FRONTEND}
release-tornjak-fe-ghcr: container-frontend
docker tag ${CONTAINER_FRONTEND_TAG} ${CONTAINER_FRONTEND_GHCR_IMAGEPATH}
docker push ${CONTAINER_FRONTEND_GHCR_IMAGEPATH}

clean:
rm -rf bin/
Expand All @@ -82,6 +79,6 @@ clean:
rm -rf ui-manager/

push:
docker push ${CONTAINER_TAG}
docker push ${CONTAINER_BACKEND_TAG}
docker push ${CONTAINER_MANAGER_TAG}
docker push ${CONTAINER_TAG_FRONTEND}
docker push ${CONTAINER_FRONTEND_TAG}
5 changes: 3 additions & 2 deletions SPIRE_BUILD_VERSIONS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
1.4.4
1.3.5
1.5.1
1.4.5
1.3.6
1.2.5
1.1.5
6 changes: 3 additions & 3 deletions build-and-push-versioned-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ VERSION=$1
IMAGE_PATH=$2
# Cleanup old dockerfiles
cleanup() {
rm -f Dockerfile.add-frontend-versions-*
rm -f Dockerfile.add-backend-versions-*
}

helptext() {
Expand All @@ -21,7 +21,7 @@ cleanup
[[ -z $VERSION ]] && helptext
[[ -z $IMAGE_PATH ]] && helptext

sed "s/{version}/${VERSION}/g" Dockerfile.add-frontend-versions > Dockerfile.add-frontend-versions-${VERSION}
docker build -t ${IMAGE_PATH}:${VERSION} -f Dockerfile.add-frontend-versions-${VERSION} . || errExit
sed "s/{version}/${VERSION}/g" Dockerfile.add-backend-versions > Dockerfile.add-backend-versions-${VERSION}
docker build -t ${IMAGE_PATH}:${VERSION} -f Dockerfile.add-backend-versions-${VERSION} . || errExit
docker push ${IMAGE_PATH}:${VERSION} || errExit
cleanup
19 changes: 9 additions & 10 deletions run_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,19 @@ if [[ "$SPIRE_CONFIG" == "" ]] ; then
elif [[ "$TORNJAK_CONFIG" == "" ]] ; then
#echo "-t TORNJAK_CONFIG must be provided"
#exit 1
/opt/spire/tornjak-agent -c $SPIRE_CONFIG serverinfo &
/opt/spire/tornjak-agent -c $SPIRE_CONFIG http &
/opt/spire/tornjak-agent -c $SPIRE_CONFIG http --tls --cert sample-keys/tls.pem --key sample-keys/key.pem --listen-addr :20000 &
/opt/spire/tornjak-agent -c $SPIRE_CONFIG http --mtls --cert sample-keys/tls.pem --key sample-keys/key.pem --mtls-ca sample-keys/rootCA.pem --listen-addr :30000 &
/opt/spire/tornjak-backend -c $SPIRE_CONFIG serverinfo &
/opt/spire/tornjak-backend -c $SPIRE_CONFIG http &
/opt/spire/tornjak-backend -c $SPIRE_CONFIG http --tls --cert sample-keys/tls.pem --key sample-keys/key.pem --listen-addr :20000 &
/opt/spire/tornjak-backend -c $SPIRE_CONFIG http --mtls --cert sample-keys/tls.pem --key sample-keys/key.pem --mtls-ca sample-keys/rootCA.pem --listen-addr :30000 &
else
/opt/spire/tornjak-agent -c $SPIRE_CONFIG -t $TORNJAK_CONFIG serverinfo &
/opt/spire/tornjak-agent -c $SPIRE_CONFIG -t $TORNJAK_CONFIG http &
/opt/spire/tornjak-agent -c $SPIRE_CONFIG -t $TORNJAK_CONFIG http --tls --cert sample-keys/tls.pem --key sample-keys/key.pem --listen-addr :20000 &
/opt/spire/tornjak-agent -c $SPIRE_CONFIG -t $TORNJAK_CONFIG http --mtls --cert sample-keys/tls.pem --key sample-keys/key.pem --mtls-ca sample-keys/rootCA.pem --listen-addr :30000 &
/opt/spire/tornjak-backend -c $SPIRE_CONFIG -t $TORNJAK_CONFIG serverinfo &
/opt/spire/tornjak-backend -c $SPIRE_CONFIG -t $TORNJAK_CONFIG http &
/opt/spire/tornjak-backend -c $SPIRE_CONFIG -t $TORNJAK_CONFIG http --tls --cert sample-keys/tls.pem --key sample-keys/key.pem --listen-addr :20000 &
/opt/spire/tornjak-backend -c $SPIRE_CONFIG -t $TORNJAK_CONFIG http --mtls --cert sample-keys/tls.pem --key sample-keys/key.pem --mtls-ca sample-keys/rootCA.pem --listen-addr :30000 &
fi


# run
# run SPIRE

# PORT=3000 npm start --prefix ./tornjak-frontend &
/usr/bin/dumb-init /opt/spire/bin/spire-server run -config $SPIRE_CONFIG