Skip to content

Commit c7ea220

Browse files
committed
ci: Add an Action to build and push to DockerHub
1 parent f2d54e4 commit c7ea220

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

.github/workflows/publish.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build and Publish Docker Image to Docker Hub
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: DockerHub Login
15+
uses: docker/login-action@v2.1.0
16+
with:
17+
username: ${{ secrets.DOCKERHUB_USERNAME }}
18+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
19+
20+
- name: Build the Docker image
21+
run: docker build . --file Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/devops
22+
23+
- name: Docker Push
24+
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/devops

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nginx:1.23.2
1+
FROM nginx:1.23.3-alpine
22
WORKDIR /usr/share/nginx/html
33
COPY . .
44
EXPOSE 80

docker-compose.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ version: '3.9'
22

33
services:
44
devops-website:
5-
container_name: website
5+
container_name: devops-website
66
build:
77
context: .
88
dockerfile: Dockerfile
9+
image: devops-website
910
ports:
1011
- 8000:80

0 commit comments

Comments
 (0)