diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..a552987 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,42 @@ +name: Deploy to Server + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + container: + image: alpine:latest + steps: + - name: Install SSH and Networking Tools + run: apk add --no-cache openssh-client iproute2 git + + - name: Configure SSH Key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + echo "StrictHostKeyChecking no" > ~/.ssh/config + + - name: Execute Remote Deployment + run: | + HOST_IP=$(ip route | awk '/default/ { print $3 }') + echo "==> Detected Host IP: $HOST_IP" + + ssh adipu@$HOST_IP << 'EOF' + set -e + echo "==> Navigating to project directory..." + cd ~/SousChefAI + echo "==> Pulling latest code..." + git pull origin main + + echo "==> Building and starting container..." + docker-compose up -d --build + + echo "==> Pruning old images..." + docker image prune -f + echo "==> Deployment Complete!" + EOF diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8f885b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:20-alpine AS build +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +FROM nginx:alpine +COPY --from=build /app/dist /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..62678f0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + app: + build: . + restart: unless-stopped + ports: + - "8080:80" # Maps port 8080 on the host to port 80 in the container + deploy: + resources: + limits: + memory: 128M