-
In the docker-compose.yml file add new service by appending the service spec to the end
<service-name>: image: "<docker-image-url>" env_file: - .envs/.<service-name> ports: - "<port>:<port>"
NB: Ensure the port your using isn't alreday in use
You can omit the env_file if your application is not using any environment variables, as simpe as<service-name>: image: "<docker-image-url>" ports: - "<port>:<port>"
-
If your application made use of an env_file then open the init.sh file and add your above to the array on line 4
-
You can now create a PR for and for your services to spin up
-
Now the service spins up but you would not be able to view anything because app running on any port apart from the default isn't visibe outside the box. So you'll have to add this service to the [turntabl API Gateway] (https://github.com/idawud/TurntablAPIGateway.git). You can clone this repo and create a PR after making these additions
- Open the src/main/java/io/tuntabl/TurntablApiGatewayApplication.java
- If your service is an API or only Endpoint, then you should add security layer for access using OPEN ID Connect by modifying this file to add route NB: use above
.route("<service-name> ", r -> r.path("/<service-name> /**") .filters(f -> f.rewritePath("/<service-name> /(?<segment>.*)", "/${segment}") .filter(JWTValidationFilter.apply(JWTValidationFilter.newConfig()))) .uri("http://<service-name>:<service-port>"))
Else you can omit the security during development and add it when you're done or omit it if its a UI app by adding route as
.route("<service-name> ", r -> r.path("/<service-name> /**") .filters(f -> f.rewritePath("/<service-name> /(?<segment>.*)", "/${segment}")) .uri("http://<service-name>:<service-port>"))
-
If your PR is merged you can now access the service at http://api.services.turntabl.io//[all the routes in this service]
The primary method we use is the GitHub Action
- Docker & ECR for images
- Services image could be deployed to either DockerHub or the AWS ECR
-
- add your username and password to your secrets on github
env: USERNAME: ${{ secrets.DOCKER_USERNAME }} PASSWORD: ${{ secrets.DOCKER_PASSWORD }} IMAGE_NAME: "<image-name>" TAG_NAME: "latest"
-
- create a repo on ecr first as will need this url and an access key & secret will also be need to push to ecr repo
env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} IMAGE_URI: "xxxx.dkr.ecr.us-east-2.amazonaws.com/IMAGE_NAME" TAG_NAME: "latest" LATEST: "true"
This will build your Dockerfile and push it to your dockerHub repo with the image_name and tag - Secrets
- The secrets is under your Project's repository setting. You should be able to add and remove secrets
- Click on the Add a new secret and provide the Name and Value. The Name should match the accessed value in the workflow yml file. E.g. Name: DOCKER_USERNAME , Value: turntabl
- Provide for all the secrets variable. Which include the EC2 var for the private pem file and EC2_HOST to be used to connect to the aws box
- If your using an environment from above. You should add an ENV secret which will be read and updated to your env_file on each action. So if you want to update your environment variables, you delete the ENV and create new one with same name. The ENV Value should in the format
name=value name2=value2 PORT=50000 URL=http://api.services.turntabl.io/myservice
- You can use a sample in the github-action-samples directory by just copy and pasting in a .yml in the dir .github/workflows" in your project root directory.
- You can check in the Action tab of your GitHub Repo for each change whetehr successful or not