Skip to content

Commit

Permalink
Switch to vite
Browse files Browse the repository at this point in the history
  • Loading branch information
nyatindopatrick committed Sep 26, 2024
1 parent 31f4891 commit 32ab81c
Show file tree
Hide file tree
Showing 32 changed files with 7,039 additions and 31,331 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_SERVER_BASE_URL=https://chanjoke.intellisoftkenya.com
111 changes: 111 additions & 0 deletions .github/workflows/deploy.yml
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
100 changes: 0 additions & 100 deletions .github/workflows/integrate.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docker/nginx.conf
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;
Expand Down
22 changes: 22 additions & 0 deletions index.html
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>
Loading

0 comments on commit 32ab81c

Please sign in to comment.