-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made dockerfile for services and cd pipeline
- Loading branch information
Showing
88 changed files
with
333 additions
and
18,772 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Build and Deploy the server to EC2 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'services/**' | ||
- '.github/**' | ||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Check out the repository | ||
- name: Check Out Repo | ||
uses: actions/checkout@v3 | ||
|
||
# Log in to Docker Hub | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
# Build and push Docker image to Docker Hub | ||
- name: Build and Push Docker Image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./services | ||
file: ./services/Dockerfile | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/hubble-services:latest | ||
|
||
# Verify the pushed image | ||
- name: Verify Pushed Image | ||
run: docker pull ${{ secrets.DOCKER_USERNAME }}/hubble-services:latest | ||
|
||
# Deploy the Docker image to an EC2 instance | ||
- name: Deploy to EC2 | ||
uses: appleboy/ssh-action@v0.1.8 | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_KEY }} | ||
script: | | ||
# Pull the latest application image | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/hubble-services:latest | ||
# Pull the latest Redis image | ||
sudo docker pull redis:alpine | ||
# Stop and remove existing containers | ||
sudo docker stop hubble-backend || true | ||
sudo docker rm hubble-backend || true | ||
sudo docker stop redis-container || true | ||
sudo docker rm redis-container || true | ||
# Run Redis container | ||
sudo docker run -d --name redis-container -p ${{ secrets.REDIS_PORT }}:6379 redis:alpine | ||
# Run application server container | ||
sudo docker run -d --name hubble-backend -p ${{ secrets.PORT}}:${{ secrets.PORT}} -e "REDIS_PORT=${{ secrets.REDIS_PORT}}" -e "REDIS_HOST=${{ secrets.REDIS_HOST}}" -e "PORT=${{ secrets.PORT}}" ${{ secrets.DOCKER_USERNAME }}/hubble-services:latest |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.