Deploy your web apps with ease.
-
Go version go1.23.2
-
Install air package for live reload
go install github.com/air-verse/air@latest
-
Clone the repository.
- Run the api-server (main backend server)
cd api-server
Install the dependencies
go mod download
Run the Postgre SQL database
docker run --name pg-docker -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=mydb -p 5432:5432 -d postgres
Export the Database URI
export DBURI="host=localhost user=admin password=secret dbname=mydb port=5432 sslmode=disable TimeZone=UTC"
Export the Session secret
export SESSION_KEY=mysecret
Run the API
air --build.cmd "go build -o bin/api ./cmd/web/" --build.bin "./bin/api"
this API will start at port 9000, check the api at 127.0.0.1:9000/health
.
- Run the reverse-proxy API
cd reverse-proxy
go mod download
air --build.cmd "go build -o bin/api ./cmd/web/main.go" --build.bin "./bin/api"
- Build the build-server container Go to the Build server directory
cd build-server
Build the image
docker build -t scale-mesh/build-server-container-image .
Run the container, it require 2 env variables.
GITHUB_REPO_URL
projectID
-
Build Server
-
Reverse Proxy API
-
Main API Server
-
Frontend Server
-
Log Collection Pipeline
To build the code and push the artifacts to the S3 bucket.
It is a custom Docker container which uses the GitHub repo url, clones it and then build it and push them to SS3 bucket
Structure
- Dockerfile
- entry.sh
- main.go
It is a Multistage Docker build, which builds the Go binary in first stage and then run the bianry in 2nd stage to build the user's web app code and push the build artifacts to the S3 bucket.
Build Server image is pushed to AWS ECR, and then a ECS cluster & Task defination are created to run a container from the ECR image, and after task completed, it'll destroy the container.
S3 buckets are uploaded in this path __output/{projectID}/
Main backend API, via which user interacts with the Web app.
- User Signup/login
- Save the user's web app project info(GitHub repo url, name) to deploy.
- Deploy the web app.
-
cmd/web/ Contains all the API and business logic.
-
pkg Contains the ancillary non-application-specfic code, which could potentially be reused.
-
Contains the Database models and methods.
- GET
/health
to check health of the API. - POST
/deploy
to deploy the project. - POST
/project
to save the info of the project. - POST
/user/signup
to signup. - POST
/user/login
to login. - POST
/user/logout
to logout.
To serve the user Web App dynamically using the unique project id.
Serve a basic HTML template for user to interact with the application.
Build-Server container pushes the logs to the Redis using pub/sub feature and a web socker server is subscribing to the redis channel.
- To build and push the image to Docker Hub registry of API server.
-
k8s
directory contains the YAML files to deploy the web app on k8s. -
How to deploy
- Create Namespace.
- Create secret
- Create DB
- Deploy service.