Skip to content

Commit

Permalink
build: dockerize backend
Browse files Browse the repository at this point in the history
  • Loading branch information
SverreNystad committed Jul 17, 2024
1 parent d3e61bd commit 084bcdb
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 15 deletions.
34 changes: 34 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose.y*ml
**/target
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/vendor
LICENSE
README.md
15 changes: 15 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM gradle:8.9.0-jdk-21-and-22-alpine AS build
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle build -x test -PskipSpotless --no-daemon

FROM eclipse-temurin:21.0.2_13-jdk

EXPOSE 8080

RUN mkdir /app

COPY --from=build /home/gradle/src/build/libs/*.jar /app/spring-boot-application.jar


ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseContainerSupport", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/app/spring-boot-application.jar"]
32 changes: 17 additions & 15 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,25 @@ tasks.withType<Test> {
}

spotless {
// Optional: limit format enforcement to just the files changed by this feature branch
format("misc") {
// Define the files to apply `misc` to
target("*.gradle.kts", "*.gradle", ".gitattributes", ".gitignore")
if (!project.hasProperty("skipSpotless")) {
// Optional: limit format enforcement to just the files changed by this feature branch
format("misc") {
// Define the files to apply `misc` to
target("*.gradle.kts", "*.gradle", ".gitattributes", ".gitignore")

// Define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
// Define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces() // or spaces. Takes an integer argument if you don"t like 4
endWithNewline()
}

java {
target("src/**/*.java") // Define the target for Java files
palantirJavaFormat()
importOrder("java|javax", "board.master", "", "\\#board.master", "\\#")
removeUnusedImports()
formatAnnotations()
java {
target("src/**/*.java") // Define the target for Java files
palantirJavaFormat()
importOrder("java|javax", "board.master", "", "\\#board.master", "\\#")
removeUnusedImports()
formatAnnotations()
}
}
}

Expand Down
50 changes: 50 additions & 0 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Docker Compose reference guide at
# https://docs.docker.com/go/compose-spec-reference/

# Here the instructions define your application as a service called "server".
# This service is built from the Dockerfile in the current directory.
# You can add other services your application may depend on here, such as a
# database or a cache. For examples, see the Awesome Compose repository:
# https://github.com/docker/awesome-compose
services:
backend-board-master:
build:
context: .
image: board-master/backend:latest
ports:
- 8080:8080
container_name: backend-board-master

# The commented out section below is an example of how to define a PostgreSQL
# database that your application can use. `depends_on` tells Docker Compose to
# start the database before your application. The `db-data` volume persists the
# database data between container restarts. The `db-password` secret is used
# to set the database password. You must create `db/password.txt` and add
# a password of your choosing to it before running `docker-compose up`.
# depends_on:
# db:
# condition: service_healthy
# db:
# image: postgres
# restart: always
# user: postgres
# secrets:
# - db-password
# volumes:
# - db-data:/var/lib/postgresql/data
# environment:
# - POSTGRES_DB=example
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
# expose:
# - 5432
# healthcheck:
# test: [ "CMD", "pg_isready" ]
# interval: 10s
# timeout: 5s
# retries: 5
# volumes:
# db-data:
# secrets:
# db-password:
# file: db/password.txt
Empty file added docs/manuals/developer_setup.md
Empty file.

0 comments on commit 084bcdb

Please sign in to comment.