-
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 status checks…
build: add docker staging
1 parent
d42c155
commit e1f2b15
Showing
3 changed files
with
73 additions
and
0 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,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 |
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,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"] |
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,10 @@ | ||
version: "3.8" | ||
services: | ||
strapi: | ||
build: | ||
context: . | ||
ports: | ||
- "1337:1337" | ||
env_file: | ||
- /home/rheumac/.env | ||
restart: always |