Коммит 98756fd3 создал по автору Radch-enko's avatar Radch-enko
Просмотр файлов

Remove Docker setup and introduce `application-local.yml` for local development

- Deleted `docker-compose.yml` and `Dockerfile` to streamline development setup.
- Added `application-local.yml` for local profile configuration, enabling development in a disconnected network environment.
- Updated `.gitignore` to include `.env` file path for local environment variables.
- Enhanced `build.gradle.kts` with deployment tasks for production and development environments.
владелец 1ee217a0
...@@ -52,7 +52,7 @@ logs/ ...@@ -52,7 +52,7 @@ logs/
**/application-local.properties **/application-local.properties
### Docker ### ### Docker ###
.env backend/app/src/main/resources/.env
docker-compose.override.yml docker-compose.override.yml
### Coverage reports ### ### Coverage reports ###
......
# Stage 1: Build the application
FROM gradle:7.6.1-jdk17 AS build
WORKDIR /app
# Copy the gradle files first to leverage Docker cache
COPY gradle/ gradle/
COPY gradlew .
COPY gradlew.bat .
COPY settings.gradle.kts .
COPY build.gradle.kts .
COPY gradle.properties .
COPY build-logic/ build-logic/
# Copy the source code
COPY backend/ backend/
# Build the application
RUN ./gradlew :backend:app:bootJar --no-daemon -Dorg.gradle.jvmargs="-Xmx2048m"
# Stage 2: Run the application
FROM eclipse-temurin:17-jre
# Install curl for health checks
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the built jar file from the build stage
COPY --from=build /app/backend/app/build/libs/*.jar app.jar
# Expose the port
EXPOSE 8080
# Run the application
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
...@@ -21,3 +21,81 @@ dependencies { ...@@ -21,3 +21,81 @@ dependencies {
// .env file support // .env file support
implementation("me.paulschwarz:spring-dotenv:4.0.0") implementation("me.paulschwarz:spring-dotenv:4.0.0")
} }
// Deployment tasks
// Usage:
// ./gradlew deployProd -PremoteUser=user -PremoteHost=hostname -PremotePath=/path/to/deploy
// ./gradlew deployDev -PremoteUser=user -PremoteHost=hostname -PremotePath=/path/to/deploy
//
// Parameters:
// - remoteUser: SSH username for the remote server
// - remoteHost: Hostname or IP address of the remote server
// - remotePath: Path on the remote server where the application will be deployed
//
// The deployment tasks will:
// 1. Build the application JAR (with -dev suffix for development environment)
// 2. Copy the JAR to the deploy directory and rename it to boot.jar
// 3. Copy the deploy directory to the remote server
tasks.register("deployProd") {
group = "deployment"
description = "Deploys the application to production environment"
dependsOn("bootJar")
doLast {
// Get deployment parameters
val remoteUser = project.findProperty("remoteUser") ?: "remoteUser"
val remoteHost = project.findProperty("remoteHost") ?: "remoteHost"
val remotePath = project.findProperty("remotePath") ?: "remotePath"
val jarVersion = project.version.toString()
// Create deploy directory if it doesn't exist
mkdir("${rootProject.projectDir}/deploy/prod")
// Copy the JAR file to the deploy folder and rename it
copy {
from("${project.buildDir}/libs/app-${jarVersion}-boot.jar")
into("${rootProject.projectDir}/deploy/prod")
}
// Copy the deploy directory to the remote server
exec {
commandLine("scp", "-r", "${rootProject.projectDir}/deploy/prod", "${remoteUser}@${remoteHost}:${remotePath}")
}
println("Production deployment completed successfully.")
}
}
tasks.register("deployDev") {
group = "deployment"
description = "Deploys the application to dev environment"
dependsOn("bootJar")
doLast {
// Get deployment parameters
val remoteUser = project.findProperty("remoteUser") ?: "remoteUser"
val remoteHost = project.findProperty("remoteHost") ?: "remoteHost"
val remotePath = project.findProperty("remotePath") ?: "remotePath"
val jarVersion = project.version.toString()
// Create deploy directory if it doesn't exist
mkdir("${rootProject.projectDir}/deploy/dev")
// Copy the JAR file to the deploy folder and rename it
copy {
from("${project.buildDir}/libs/app-${jarVersion}-boot.jar")
into("${rootProject.projectDir}/deploy/dev")
rename { "app-${jarVersion}-dev-boot.jar" }
}
// Copy the deploy directory to the remote server
exec {
commandLine("scp", "-r", "${rootProject.projectDir}/deploy/dev", "${remoteUser}@${remoteHost}:${remotePath}")
}
println("Development deployment completed successfully.")
}
}
# Path to the .env file relative to the project root
dotenv.path=.env
\ No newline at end of file
# Local profile configuration
# This profile aims to configure an environment that can be developed even if the network is disconnected.
spring:
jpa:
hibernate:
ddl-auto: update # Use update for local development to automatically update schema
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: true
show_sql: true # Show SQL for local debugging
use_sql_comments: true
open-in-view: false
flyway:
enabled: ${MIGRATIONS_ENABLE:true}
baseline-on-migrate: true
locations: classpath:db/migration
table: flyway_schema_history
logging:
level:
root: ${LOG_LEVEL:INFO}
org.hibernate.SQL: DEBUG
org.hibernate.type.descriptor.sql.BasicBinder: TRACE
band.effective.office.backend: ${LOG_LEVEL:DEBUG}
# Application Configuration
application:
url: ${APPLICATION_URL:http://localhost:8080}
# Calendar provider configuration
calendar:
provider: google # Options: google, dummy
default-calendar: ${DEFAULT_CALENDAR} # Default calendar ID
application-name: ${CALENDAR_APPLICATION_NAME} # Application name for Google Calendar API
delegated-user: ${CALENDAR_DELEGATED_USER} # Email of the user to impersonate (optional)
credentials.file: ${GOOGLE_CREDENTIALS_FILE:classpath:google-credentials.json}
# Calendar subscription configuration
subscription:
default-app-email: ${DEFAULT_APP_EMAIL}
google-credentials: ${GOOGLE_CREDENTIALS_FILE:classpath:google-credentials.json}
application-url: ${APPLICATION_URL}
test-application-url: ${TEST_APPLICATION_URL}
calendars: ${CALENDARS}
test-calendars: ${TEST_CALENDARS}
firebase-credentials: ${FIREBASE_CREDENTIALS:classpath:firebase-credentials.json}
# Note: For local development, you need to set the JSON_GOOGLE_CREDENTIALS environment variable
# with the contents of your Google service account credentials JSON file
version: '3.8'
services:
app:
build:
context: ..
dockerfile: backend/Dockerfile
container_name: effective-office-app
ports:
- "8080:8080"
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/effectiveoffice
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER}
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD}
depends_on:
db:
condition: service_healthy
networks:
- effective-office-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/actuator/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 40s
db:
image: postgres:15-alpine
container_name: effective-office-db
ports:
- "5432:5432"
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- postgres-data:/var/lib/postgresql/data
networks:
- effective-office-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
networks:
effective-office-network:
driver: bridge
volumes:
postgres-data:
...@@ -9,6 +9,6 @@ kotlin.incremental=true ...@@ -9,6 +9,6 @@ kotlin.incremental=true
# Project properties # Project properties
group=band.effective.office group=band.effective.office
version=0.0.1-SNAPSHOT version=0.0.1
android.useAndroidX=true android.useAndroidX=true
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать