Skip to content

Commit

Permalink
build: add docker staging
Browse files Browse the repository at this point in the history
pawan-live committed Dec 20, 2024

Verified

This commit was signed with the committer’s verified signature.
qdm12 Quentin McGaw
1 parent d42c155 commit e1f2b15
Showing 3 changed files with 73 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Deploy to Staging via Docker Hub

on:
push:
branches:
- develop

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

- name: Build the Docker image
run: |
docker build -t pawanlive/rc-api:latest .
- name: Push the Docker image to Docker Hub
run: |
docker push pawanlive/rc-api:latest
- name: Deploy to Azure VM
env:
SSH_PRIVATE_KEY: ${{ secrets.AZURE_VM_SSH_KEY }}
run: |
echo "$SSH_PRIVATE_KEY" > ssh_key
chmod 600 ssh_key
ssh -i ssh_key -o StrictHostKeyChecking=no rheumac@${{ secrets.AZURE_VM_IP }} << 'EOF'
# Pull and run the Docker image
docker pull pawanlive/rc-api:latest
docker stop rc-api || true
docker rm rc-api || true
docker run -d --name rc-api \
-p 1337:1337 \
--env-file /home/rheumac/.env \
pawanlive/rc-api:latest
# Exit the SSH session
exit
EOF
rm ssh_key
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:18

# Set working directory
WORKDIR /usr/src/app

# Copy package files and install dependencies
COPY package*.json ./
RUN npm install --production

# Copy application files
COPY . .

# Expose the default Strapi port
EXPOSE 1337

# Run the application
CMD ["npm", "start"]
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3.8"
services:
strapi:
build:
context: .
ports:
- "1337:1337"
env_file:
- /home/rheumac/.env
restart: always

0 comments on commit e1f2b15

Please sign in to comment.