Skip to content

Commit

Permalink
ci: add initial pipeline (#5)
Browse files Browse the repository at this point in the history
* ci: add first pass docker scripts

* ci: add volumes and more configuration for docker containers

* chore: docker compose tweaks

* ci: add ci.yml file

* chore: pass java version into build step title

---------

Co-authored-by: steve <[email protected]>
  • Loading branch information
gm112 and MGZero authored Sep 24, 2024
1 parent 011801c commit 3cac7a0
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [17]
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java-version}} for x64
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
architecture: x64
cache: maven
- name: Build with Maven
run: mvn clean compile package -Dmaven.test.skip=true
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM maven:3.9-eclipse-temurin-17 AS build

RUN mkdir -p /usr/src/zfgcbb
COPY . /usr/src/zfgcbb

WORKDIR /usr/src/zfgcbb

RUN mvn clean compile package -Dmaven.test.skip=true

FROM postgres:16 AS database

#RUN echo "CREATE DATABASE zfgcbb; CREATE USER $SPRING_DATASOURCE_USERNAME; GRANT ALL PRIVILEGES ON DATABASE zfgcbb TO $SPRING_DATASOURCE_USERNAME;" > /docker-entrypoint-initdb.d/init.sql

FROM tomcat:jre17-temurin-jammy AS deploy

COPY --from=build /usr/src/zfgcbb/target/*.war /usr/local/tomcat/webapps/

EXPOSE 8080

CMD ["catalina.sh", "run"]
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
services:
postgresql:
build:
context: .
dockerfile: Dockerfile
target: database
container_name: zfgcbb_postgresql
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=123456
- POSTGRES_DB=zfgcbb
ports:
- "5432:5432"
volumes:
- data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready" ,"-d", "zfgcbb"]
interval: 30s
timeout: 60s
retries: 5
start_period: 80s

zfgcbb:
build:
context: .
dockerfile: Dockerfile
target: deploy
ports:
- "8080:8080"
volumes:
- logs:/usr/src/app/logs
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://zfgcbb_postgresql:5432/zfgcbb
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=123456
- SPRING_JPA_HIBERNATE_DDL_AUTO=create-drop
depends_on:
- postgresql

volumes:
data:
logs:
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<properties>
<java.version>17</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down

0 comments on commit 3cac7a0

Please sign in to comment.