Skip to content

Commit

Permalink
Reorganize Root Directory (#315)
Browse files Browse the repository at this point in the history
* Moved golang files up a directory

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* Remove run_tornjak script

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* Adjusted Gofiles to reflect new structure

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* Moved docker-compose file to examples folder

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* Reverting accidentally added changes

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* Moved Keycloak example

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* moved backend script

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* renamed tornjak frontend folder

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* adjusted lcoation of frontend Dockerfiles

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* re-add Dockerfile for frontend

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* add accidentally ignored packages

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* fixed rebase error

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

---------

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>
  • Loading branch information
maia-iyer committed Mar 20, 2024
1 parent e7f6ec9 commit 72f1216
Show file tree
Hide file tree
Showing 126 changed files with 15,858 additions and 177 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/master-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Add ubi prefix
run: echo "IMAGE_TAG_PREFIX=ubi-" >> $GITHUB_ENV
- name: Set frontend Dockerfile
run: echo "DOCKERFILE_FRONTEND=Dockerfile.frontend-container.ubi" >> $GITHUB_ENV
run: echo "DOCKERFILE_FRONTEND=frontend/Dockerfile.frontend-container.ubi" >> $GITHUB_ENV
- name: Set backend Dockerfile
run: echo "DOCKERFILE_BACKEND=Dockerfile.backend-container.ubi" >> $GITHUB_ENV

Expand Down
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
vendor

# dependencies
tornjak-frontend/node_modules
tornjak-frontend/.pnp
tornjak-frontend/.pnp.js
frontend/node_modules
frontend/.pnp
frontend/.pnp.js

# testing
tornjak-frontend/coverage
frontend/coverage

# production
tornjak-frontend/build
frontend/build

# misc
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.backend-container
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /opt/spire
ENTRYPOINT ["/opt/spire/run_backend.sh"]

# Add init
COPY run_backend.sh run_backend.sh
COPY scripts/run_backend.sh run_backend.sh
COPY bin/tornjak-backend tornjak-backend

# add a version link to the image description
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.backend-container.ubi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /opt/spire
ENTRYPOINT ["/opt/spire/run_backend.sh"]

# Add init
COPY run_backend.sh run_backend.sh
COPY scripts/run_backend.sh run_backend.sh
COPY bin/tornjak-backend tornjak-backend

# add a version link to the image description
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ IMAGE_TAG_PREFIX ?=

## dockerfile for each container default to alpine base image
DOCKERFILE_BACKEND ?= Dockerfile.backend-container
DOCKERFILE_FRONTEND ?= Dockerfile.frontend-container
DOCKERFILE_FRONTEND ?= frontend/Dockerfile.frontend-container

BINARIES=tornjak-backend tornjak-manager
IMAGES=$(BINARIES) tornjak-frontend
Expand Down Expand Up @@ -56,22 +56,22 @@ vendor: tidy ## Vendor go modules
PHONY: binaries
binaries: $(addprefix bin/,$(BINARIES)) ## Build bin/tornjak-backend and bin/tornjak-manager binaries

bin/tornjak-backend: tornjak-backend/cmd/agent $(GO_FILES) | vendor ## Build tornjak-backend binary
bin/tornjak-backend: cmd/agent $(GO_FILES) | vendor ## Build tornjak-backend binary
# 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:$(GO_VERSION) \
/bin/sh -c "go build --tags 'sqlite_json' -o agent ./$</main.go; go build --tags 'sqlite_json' -mod=vendor -ldflags '-s -w -linkmode external -extldflags "-static"' -o $@ ./$</main.go"

bin/tornjak-manager: tornjak-backend/cmd/manager $(GO_FILES) | vendor ## Build bin/tornjak-manager binary
bin/tornjak-manager: cmd/manager $(GO_FILES) | vendor ## Build bin/tornjak-manager binary
# 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:$(GO_VERSION) \
/bin/sh -c "go build --tags 'sqlite_json' -o tornjak-manager ./$</main.go; go build --tags 'sqlite_json' -mod=vendor -ldflags '-s -w -linkmode external -extldflags "-static"' -o $@ ./$</main.go"

frontend-local-build: ## Build tornjak-frontend
npm install --prefix tornjak-frontend
rm -rf tornjak-frontend/build
rm -rf frontend/build
npm run build --prefix tornjak-frontend
rm -rf frontend-local-build
cp -r tornjak-frontend/build frontend-local-build
cp -r frontend/build frontend-local-build

##@ Container images:

Expand All @@ -97,7 +97,7 @@ image-tornjak-frontend: ## Build image for tornjak-frontend

.PHONY: compose-frontend
compose-frontend: ## Run frontend using docker-compose
docker-compose -f docker-compose-frontend.yml up --build --force-recreate -d
docker-compose -f examples/docker-compose/frontend.yml up --build --force-recreate -d
docker tag tornjak-public_tornjak-frontend:latest $(CONTAINER_FRONTEND_TAG):$(VERSION)

##@ Release:
Expand Down
2 changes: 1 addition & 1 deletion tornjak-backend/api/agent/api.go → api/agent/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
types "github.com/spiffe/spire-api-sdk/proto/spire/api/types"
"google.golang.org/grpc/health/grpc_health_v1"

tornjakTypes "github.com/spiffe/tornjak/tornjak-backend/pkg/agent/types"
tornjakTypes "github.com/spiffe/tornjak/pkg/agent/types"
)

type HealthcheckRequest grpc_health_v1.HealthCheckRequest
Expand Down
4 changes: 2 additions & 2 deletions tornjak-backend/api/agent/server.go → api/agent/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/hashicorp/hcl/hcl/token"
"github.com/pkg/errors"

auth "github.com/spiffe/tornjak/tornjak-backend/pkg/agent/auth"
agentdb "github.com/spiffe/tornjak/tornjak-backend/pkg/agent/db"
auth "github.com/spiffe/tornjak/pkg/agent/auth"
agentdb "github.com/spiffe/tornjak/pkg/agent/db"
)

type Server struct {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tornjak-backend/api/manager/api.go → api/manager/api.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package managerapi

import (
managertypes "github.com/spiffe/tornjak/tornjak-backend/pkg/manager/types"
managertypes "github.com/spiffe/tornjak/pkg/manager/types"

"github.com/pkg/errors"
//types "github.com/spiffe/spire/proto/spire/types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"

"github.com/gorilla/mux"
managerdb "github.com/spiffe/tornjak/tornjak-backend/pkg/manager/db"
managerdb "github.com/spiffe/tornjak/pkg/manager/db"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion tornjak-backend/cmd/agent/main.go → cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/pkg/errors"
"github.com/spiffe/spire/cmd/spire-server/cli/run"
"github.com/spiffe/spire/pkg/common/catalog"
agentapi "github.com/spiffe/tornjak/tornjak-backend/api/agent"
agentapi "github.com/spiffe/tornjak/api/agent"
"github.com/urfave/cli/v2"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"log"

managerapi "github.com/spiffe/tornjak/tornjak-backend/api/manager"
managerapi "github.com/spiffe/tornjak/api/manager"
)

func main() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions examples/docker-compose/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3.8"
services:
tornjak-frontend:
build:
context: ../../
dockerfile: Dockerfile.frontend-container
container_name: tornjak-frontend
restart: always
ports:
- "3000:8080"
environment:
- "PORT_FE=8080"
- "REACT_APP_API_SERVER_URI=http://localhost:10000"
# - "REACT_APP_AUTH_SERVER_URI=http://localhost:8080"
- REACT_APP_SPIRE_HEALTH_CHECK_ENABLE=false
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Build stage
FROM node:18-alpine3.14 AS build
WORKDIR /usr/src/app
COPY tornjak-frontend .
COPY frontend .
RUN npm install && \
npm run build

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Build stage
FROM registry.access.redhat.com/ubi8/nodejs-18:latest AS build
WORKDIR /opt/app-root/src
COPY --chown=1001:0 tornjak-frontend .
COPY --chown=1001:0 frontend .
RUN npm install && \
npm run build

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 72f1216

Please sign in to comment.