Skip to content

Commit 7bd1a54

Browse files
committed
Add Docker CI workflow for automated image build and deployment
1 parent 353ee6a commit 7bd1a54

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/docker.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Docker CI
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
workflow_dispatch:
7+
8+
jobs:
9+
docker:
10+
runs-on: 'ubuntu-latest'
11+
12+
steps:
13+
- name: Clone repository
14+
uses: actions/checkout@v4
15+
16+
- name: Login to Docker Hub
17+
uses: docker/login-action@v3
18+
with:
19+
username: ${{ secrets.APP_DOCKER_USERNAME }}
20+
password: ${{ secrets.APP_DOCKER_PASSWORD }}
21+
22+
- name: Build Docker image
23+
run: |
24+
docker build -t mrepol742/phpspa-example:latest .
25+
26+
- name: Push Docker image
27+
run: |
28+
docker push mrepol742/phpspa-example:latest
29+
30+
- name: Run Docker container
31+
run: |
32+
docker run -d -p 8080:80 --name phpspa-example mrepol742/phpspa-example:latest
33+
34+
- name: Check container logs
35+
run: |
36+
docker logs phpspa-example
37+
38+
- name: Stop and remove container
39+
if: always()
40+
run: |
41+
docker stop phpspa-example
42+
docker rm phpspa-example

0 commit comments

Comments
 (0)