Skip to content

Commit 0804b5f

Browse files
authored
Merge pull request #46 from ArielMAJ/release/1.0.0
Release/1.0.0
2 parents 0278c32 + cb58f2f commit 0804b5f

31 files changed

Lines changed: 294 additions & 643 deletions

.env.example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ POSTGRES_DATABASE=finances
55
POSTGRES_PORT=5432
66
POSTGRES_CREATE_DROP=update
77

8-
SECRET_KEY=
8+
CORS_ALLOWED_ORIGINS=http://localhost:4200
9+
SWAGGER_ENABLED=false
10+
11+
JWT_EXPIRATION_TIME=3600000
12+
SECRET_KEY=

Dockerfile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
FROM maven:3.9.9-ibm-semeru-21-jammy
1+
# --- Build stage ---
2+
FROM maven:3.9.15-amazoncorretto-21-alpine AS builder
23

3-
WORKDIR /
4-
5-
COPY .mvn/ .mvn
6-
COPY mvnw pom.xml ./
7-
RUN ./mvnw dependency:go-offline
4+
WORKDIR /build
85

6+
COPY pom.xml ./
97
COPY src ./src
8+
RUN mvn package -DskipTests -B
9+
10+
# --- Runtime stage ---
11+
FROM eclipse-temurin:21-jre-alpine
12+
13+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
14+
15+
WORKDIR /app
16+
17+
COPY --from=builder /build/target/*.jar app.jar
18+
19+
USER appuser
1020

1121
EXPOSE 8080
12-
CMD ["./mvnw", "spring-boot:run"]
22+
ENTRYPOINT ["java", "-jar", "app.jar"]

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ recreate: down ## Rebuild and recreate all containers.
1717

1818
.PHONY: run
1919
run: ## Run the project locally.
20-
./mvnw spring-boot:run
20+
mvn spring-boot:run
2121

2222
.PHONY: install
2323
install: ## Install dependencies
@@ -39,6 +39,17 @@ up-test-database: ## Start test database container.
3939
generate-secret-key:
4040
@node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
4141

42+
.PHONY: setup-env
43+
setup-env: ## Create .env from .env.example and generate a SECRET_KEY.
44+
@if [ -f .env ]; then \
45+
echo ".env already exists. Remove it first if you want to regenerate."; \
46+
exit 1; \
47+
fi
48+
@cp .env.example .env
49+
@SECRET=$$(node -e "process.stdout.write(require('crypto').randomBytes(32).toString('hex'))"); \
50+
perl -i -pe "s/^SECRET_KEY=.*/SECRET_KEY=$$SECRET/" .env
51+
@echo ".env created with a generated SECRET_KEY."
52+
4253
.DEFAULT_GOAL := help
4354
help:
4455
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sed 's/Makefile://g' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

docker-compose.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ services:
1111
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
1212
POSTGRES_CREATE_DROP: ${POSTGRES_CREATE_DROP}
1313
SECRET_KEY: ${SECRET_KEY}
14+
JWT_EXPIRATION_TIME: ${JWT_EXPIRATION_TIME}
15+
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS}
16+
SWAGGER_ENABLED: ${SWAGGER_ENABLED}
1417
ports:
1518
- "8080:8080"
1619
depends_on:

mvnw

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

0 commit comments

Comments
 (0)