-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from AhmedMohamedAbdelaty/docker-compose
Add Docker and Docker Compose Support
- Loading branch information
Showing
6 changed files
with
124 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Build stage | ||
FROM eclipse-temurin:21-jdk-alpine AS builder | ||
WORKDIR /build | ||
# Copy gradle files | ||
COPY gradlew . | ||
COPY gradle gradle | ||
COPY build.gradle . | ||
COPY settings.gradle . | ||
# Make gradlew executable | ||
RUN chmod +x gradlew | ||
# Download dependencies | ||
RUN ./gradlew dependencies | ||
|
||
# Copy source code and resources | ||
COPY src src | ||
# Build the application | ||
RUN ./gradlew build -x test | ||
|
||
# Run stage | ||
FROM eclipse-temurin:21-jre-alpine | ||
WORKDIR /app | ||
# Copy the built artifact from builder stage | ||
COPY --from=builder /build/build/libs/*.jar app.jar | ||
# Copy the env.properties file | ||
COPY src/main/resources/env.properties /app/resources/env.properties | ||
EXPOSE 8080 | ||
ENTRYPOINT ["java", "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
services: | ||
postgres: | ||
image: postgres:16-alpine | ||
container_name: upwork_postgres | ||
environment: | ||
POSTGRES_USER: ${DB_USER:-postgres} | ||
POSTGRES_PASSWORD: ${DB_PASSWORD:-root} | ||
POSTGRES_DB: ${DB_NAME:-upwork} | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
- ./init-scripts:/docker-entrypoint-initdb.d | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U postgres"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
restart: unless-stopped | ||
networks: | ||
- app-network | ||
|
||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
container_name: upwork_app | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
environment: | ||
SPRING_CONFIG_LOCATION: file:/app/resources/env.properties | ||
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/${DB_NAME:-upwork} | ||
SPRING_DATASOURCE_USERNAME: ${DB_USER:-postgres} | ||
SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD:-root} | ||
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILE:-dev} | ||
ports: | ||
- "8080:8080" | ||
volumes: | ||
- ./logs:/app/logs | ||
restart: unless-stopped | ||
networks: | ||
- app-network | ||
|
||
volumes: | ||
postgres_data: | ||
driver: local | ||
|
||
networks: | ||
app-network: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters