Skip to content

Commit

Permalink
feat: add docker build and push action (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksii-honchar authored Jul 27, 2024
1 parent e7fef83 commit 85979f8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .env.dist
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
NODE_ENV=development
GITHUB_TOKEN=your-github-token
GITHUB_TOKEN=your-github-token
DOCKERHUB_USERNAME=your-dockerhub-username
23 changes: 23 additions & 0 deletions .github/workflows/docker-build-n-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build Docker image and push to Docker Hub

on:
push:
tags:
- '*'

jobs:
builds:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: sudo apt-get update && sudo apt-get install -y jq
- run: make docker-build
- run: make docker-tag-latest
- run: make docker-push
- run: docker logout
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ ifndef NODE_ENV
endif

docker-build: check-node-env ## build docker image
docker build --load -f ./Dockerfile --build-arg IMAGE_VERSION=$(IMAGE_VERSION) --build-arg IMAGE_NAME=$(IMAGE_NAME) -t $(IMAGE_NAME):$(IMAGE_VERSION) .
docker build --load -f ./Dockerfile --build-arg IMAGE_VERSION=$(IMAGE_VERSION) --build-arg IMAGE_NAME=$(IMAGE_NAME) -t $(DOCKERHUB_USERNAME)/$(IMAGE_NAME):$(IMAGE_VERSION) .

docker-push: ## push latest image to docker hub of <type>
@docker push $(DOCKERHUB_USERNAME)/$(IMAGE_NAME):$(IMAGE_VERSION)
@docker push $(DOCKERHUB_USERNAME)/$(IMAGE_NAME):latest

docker-run: check-node-env ## build docker image
docker run --rm -p 9000:9000 $(IMAGE_NAME):$(IMAGE_VERSION)

docker-tag-latest: ## tag image as latest
@docker tag $(DOCKERHUB_USERNAME)/$(IMAGE_NAME):$(IMAGE_VERSION) $(DOCKERHUB_USERNAME)/$(IMAGE_NAME):latest

logs-restart: ## restart logs stack
@docker compose -f ./ops/grafana-logs/docker-compose.logs.yaml down
@docker compose -f ./ops/grafana-logs/docker-compose.logs.yaml up -d
Expand Down

0 comments on commit 85979f8

Please sign in to comment.