Skip to content

Commit

Permalink
Merge pull request #59 from vicheanath/docker-setup
Browse files Browse the repository at this point in the history
fix: build docker
  • Loading branch information
vicheanath authored Feb 8, 2024
2 parents f5d52d2 + 7156f9f commit 23bf270
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/build-push-docker.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Build and Publish Docker Image

on:
release:
types: [created]
types: [created, published]
version: 'v*.*.*'


jobs:
build:
Expand All @@ -15,11 +23,11 @@ jobs:
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 1234
POSTGRES_DB: mini-pms
POSTGRES_DB: pms-db
ports:
- 5432:5432

options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
Expand Down Expand Up @@ -53,7 +61,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
file: ./backend/pms/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
36 changes: 34 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ name: Test and Build
on:
push:
branches: [ "main" ]
paths:
- 'backend/**'
pull_request:
branches: [ "main" ]
paths:
- 'backend/**'


jobs:
build:
Expand All @@ -37,9 +42,36 @@ jobs:
java-version: '17'
distribution: 'temurin'
cache: maven
# - name: Run Tests
# run: cd backend/pms && mvn test

- name: Build with Maven
run: cd backend/pms && mvn clean package

- name: Build with Maven
run: cd backend/pms && mvn clean package

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/mini-pms
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./backend/pms
file: ./backend/pms/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion backend/pms/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:21-ea-slim
FROM openjdk:17-jdk-alpine

WORKDIR /app

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.security.Principal;

import java.util.List;

@CrossOrigin(origins = "http://localhost:3000")
@RestController
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Favorite.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Favorite = () => {
{data.map((property) => {
return (
<Col md={4} key={property.id} className="mb-4">
<Property key={property.id} {...property} refetch={refetch} />
<Property key={property.id} {...property} refetch={refetch}/>
</Col>
)
})}
Expand Down

0 comments on commit 23bf270

Please sign in to comment.