-
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.
- Loading branch information
1 parent
31f4891
commit 32ab81c
Showing
32 changed files
with
7,039 additions
and
31,331 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 @@ | ||
VITE_SERVER_BASE_URL=https://chanjoke.intellisoftkenya.com |
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,111 @@ | ||
name: React App Deployment | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
|
||
jobs: | ||
build_and_deploy_dev: | ||
if: github.ref == 'refs/heads/develop' | ||
runs-on: ubuntu-latest | ||
environment: Dev | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Create env file | ||
run: | | ||
echo "VITE_SERVER_BASE_URL=${{ secrets.VITE_SERVER_BASE_URL }}" > .env | ||
- name: Build & push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: docker/Dockerfile.prod | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/chanjokeclient:latest | ||
build-args: | | ||
VITE_SERVER_BASE_URL=${{ secrets.VITE_SERVER_BASE_URL }} | ||
- name: Deploy to Dev server | ||
env: | ||
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }} | ||
run: | | ||
echo "$SSH_PRIVATE_KEY" > private_key && chmod 600 private_key | ||
ssh -o StrictHostKeyChecking=no -i private_key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << EOF | ||
CONTAINER_NAME=chanjoke | ||
IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/chanjokeclient:latest | ||
if docker ps -a --format '{{.Names}}' | grep -q \$CONTAINER_NAME; then | ||
echo "Stopping and removing existing container" | ||
docker stop \$CONTAINER_NAME || true | ||
docker rm \$CONTAINER_NAME || true | ||
fi | ||
echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | ||
if [ \$? -ne 0 ]; then | ||
echo "Error: Docker login failed" | ||
exit 1 | ||
fi | ||
docker pull --quiet \$IMAGE_NAME | ||
if [ \$? -ne 0 ]; then | ||
echo "Error: Failed to pull Docker image \$IMAGE_NAME" | ||
exit 1 | ||
fi | ||
sudo docker run -d --name \$CONTAINER_NAME -p 8098:3000 \$IMAGE_NAME | ||
sudo docker logout | ||
echo "Dev deployment completed successfully" | ||
EOF | ||
rm -f private_key | ||
deploy_prod: | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
environment: production | ||
steps: | ||
- name: Deploy to Production server | ||
env: | ||
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }} | ||
run: | | ||
echo "$SSH_PRIVATE_KEY" > private_key && chmod 600 private_key | ||
ssh -o StrictHostKeyChecking=no -i private_key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << EOF | ||
CONTAINER_NAME=chanjoke | ||
IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/chanjokeclient:latest | ||
if docker ps -a --format '{{.Names}}' | grep -q \$CONTAINER_NAME; then | ||
echo "Stopping and removing existing container" | ||
docker stop \$CONTAINER_NAME || true | ||
docker rm \$CONTAINER_NAME || true | ||
fi | ||
echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | ||
if [ \$? -ne 0 ]; then | ||
echo "Error: Docker login failed" | ||
exit 1 | ||
fi | ||
docker pull --quiet \$IMAGE_NAME | ||
if [ \$? -ne 0 ]; then | ||
echo "Error: Failed to pull Docker image \$IMAGE_NAME" | ||
exit 1 | ||
fi | ||
sudo docker run -d --name \$CONTAINER_NAME -p 8098:3000 \$IMAGE_NAME | ||
sudo docker logout | ||
echo "Production deployment completed successfully" | ||
EOF | ||
rm -f private_key |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
server { | ||
listen 80; | ||
listen 3000; | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
|
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,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/logo.png" /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined" | ||
rel="stylesheet" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" | ||
/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>OpenCHANJO</title> | ||
<meta name="description" content="Raising Tech Talent." /> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.