Skip to content

Commit 6e407bc

Browse files
authored
Merge pull request #49 from couchbase-examples/AV-67610-java-quickstart-using-spring-boot
AV-67610: complete quickstart code for spring boot
2 parents e2692a4 + 102713d commit 6e407bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2339
-1166
lines changed

.github/workflows/cb-service-container.yaml

Lines changed: 0 additions & 83 deletions
This file was deleted.

.github/workflows/kind-maven.yaml

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/maven.old

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/tests.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
schedule:
9+
- cron: "0 */6 * * *"
10+
11+
jobs:
12+
run_tests:
13+
name: Run Tests
14+
runs-on: ubuntu-latest
15+
env:
16+
DB_CONN_STR: ${{ vars.DB_CONN_STR }}
17+
DB_USERNAME: ${{ vars.DB_USERNAME }}
18+
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
19+
strategy:
20+
matrix:
21+
java-version: ["17", "21"]
22+
steps:
23+
- name: Update repositories
24+
run: |
25+
sudo apt update || echo "apt-update failed" # && apt -y upgrade
26+
27+
- name: Checkout ${{ github.event.repository.name }}
28+
uses: actions/checkout@v4
29+
30+
- name: Set up JDK ${{ matrix.java-version }}
31+
uses: actions/setup-java@v4
32+
with:
33+
java-version: ${{ matrix.java-version }}
34+
distribution: "adopt"
35+
cache: "maven"
36+
37+
- name: Run Maven Tests
38+
id: run
39+
run: |
40+
chmod +x mvnw
41+
./mvnw clean install -DskipTests=false -Dmaven.javadoc.skip=true -Dgpg.skip=true -B -V -e
42+
43+
- name: Report Status
44+
if: always()
45+
uses: ravsamhq/notify-slack-action@v1
46+
with:
47+
status: ${{ job.status }}
48+
notify_when: "failure"
49+
env:
50+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
*.iml
2+
.docker/
3+
.vscode/
4+
15
# maven target directory
26
target/
37
# Compiled class file

.gitpod.Dockerfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

.gitpod.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
# Define the base image for the build stage
3+
FROM eclipse-temurin:17-jdk-jammy AS build
4+
5+
# Set the environment variable for the application home directory
6+
ENV HOME=/usr/app
7+
8+
# Create the application home directory
9+
RUN mkdir -p "$HOME"
10+
11+
# Set the working directory to the application home directory
12+
WORKDIR "$HOME"
13+
14+
# Copy the entire project to the application home directory
15+
COPY . "$HOME"
16+
17+
# Build the project using Maven, skipping tests
18+
RUN --mount=type=cache,target=/root/.m2 ./mvnw -f "$HOME"/pom.xml clean package -DskipTests=true
19+
20+
# Define the base image for the final stage
21+
FROM eclipse-temurin:17-jre-jammy
22+
23+
# Set the argument for the JAR file location
24+
ARG JAR_FILE=/usr/app/target/*.jar
25+
26+
# Copy the JAR file from the build stage to the final stage
27+
COPY --from=build $JAR_FILE /app/runner.jar
28+
29+
# Expose port 8080 for the application
30+
EXPOSE 8080
31+
32+
# Set the entrypoint command to run the JAR file
33+
ENTRYPOINT java -jar /app/runner.jar
34+
35+
# This Dockerfile is used to build a Docker image for a Java Spring Boot application.
36+
# To build the image, run:
37+
# docker build -t java-springboot-quickstart .
38+
# To run the container, use:
39+
# docker run -d --name springboot-container -p 9440:8080 java-springboot-quickstart -e DB_CONN_STR=<connection_string> -e DB_USERNAME=<username> -e DB_PASSWORD=<password>

0 commit comments

Comments
 (0)