Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions backend/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# ---- Project config ----
APP_NAME := my-spring-app
JAR_FILE := target/$(APP_NAME).jar
PORT := 8080
IMAGE := $(APP_NAME):latest

MVN?=mvn

# ---- Default target ----
.PHONY: help
help:
@echo "Usage:"
@echo " make build - Clean and build the project (fast build)"
@echo " make clean - Remove build artifacts"
@echo " make test - Run unit tests"
@echo " make run - Run the app from the built jar"
@echo " make dev - Run the app via spring-boot:run (auto-reload if configured)"
@echo " make package - Package jar with maven wrapper"
@echo " build-image - Building image based on oci standard"


# ---- Build & test ----
.PHONY: build
build:
${MVN} -q -DskipTests package

.PHONY: clean
clean:
${MVN} -q clean

.PHONY: test
test:
${MVN} -q test

.PHONY: package
package:
${MVN} -q -DskipTests package

# ---- Run locally ----
# Ensure your pom builds a single executable JAR named $(APP_NAME).jar.
# You can set the finalName in pom.xml:
# <build><finalName>my-spring-app</finalName></build>
.PHONY: run
run: package
java -jar $(JAR_FILE)

# Developer mode using spring-boot:run (no JAR required)
.PHONY: dev
dev:
${MVN} -q spring-boot:run

.PHONY: build-image
build-image:
${MVN} -q spring-boot:build-image


# Print Maven project version
.PHONY: version
version:
${MVN} help:evaluate -Dexpression=project.version -q -DforceStdout

# Optional: code formatting if you use e.g. spotless or formatter plugin
.PHONY: fmt
fmt:

.PHONY: docker-run
docker-run:
docker compose up

28 changes: 28 additions & 0 deletions backend/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3.9"

services:
barbar-shop:
image: aritraghorai/burbur-shop:latest
container_name: barbar-shop
# If you build locally from the Dockerfile in the repo:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
env_file: .env
environment:
SPRING_PROFILES_ACTIVE: prod
JAVA_TOOL_OPTIONS: "-XX:MaxRAMPercentage=75.0 -XX:+ExitOnOutOfMemoryError"
SERVER_PORT: "8080"
SPRING_APPLICATION_NAME: barbar-shop
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8080/actuator/health"] # requires Spring Boot Actuator
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
read_only: true
tmpfs:
- /tmp
restart: unless-stopped
Loading