Add Docker support and environment configuration

Introduced Dockerfile, .dockerignore, and example environment file for containerization. Added compose.yml for Docker Compose setup and renamed docker-compose.dev.yml to compose.dev.yml. Updated build.gradle.kts for Java 21 and shadow plugin, and improved .gitignore and .gitattributes. Refactored Config.java to reorder ENV initialization.
This commit is contained in:
2025-11-04 21:18:28 +07:00
parent b3cc35b4c2
commit 4bf94aaad4
9 changed files with 136 additions and 8 deletions
+47
View File
@@ -0,0 +1,47 @@
**/.DS_Store
**/.classpath
**/.dockerignore
**/.env
**/.factorypath
**/.git
**/.gitignore
**/.idea
**/.project
**/.sts4-cache
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/secrets.dev.yaml
**/values.dev.yaml
**/vendor
LICENSE
README.md
**/*.class
**/*.iml
**/*.ipr
**/*.iws
**/*.log
**/.apt_generated
**/.gradle
**/.gradletasknamecache
**/.nb-gradle
**/.springBeans
**/build
**/dist
**/gradle-app.setting
**/nbbuild
**/nbdist
**/nbproject/private
*.ctxt
.mtj.tmp
hs_err_pid*
replay_pid*
+22
View File
@@ -0,0 +1,22 @@
# Copy this file to .env and customize the values for your environment
# cp .env.example .env
# Couchbase configuration
COUCHBASE_CONNECTION_STRING=localhost:8091
COUCHBASE_USERNAME=admin
COUCHBASE_PASSWORD=your_password_here
COUCHBASE_BUCKET_NAME=store_scraper
# Telegram Bot configuration
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
TELEGRAM_BOT_USERNAME=your_bot_username
# Java configuration
JAVA_OPTS=-Xmx512m
# Logging configuration
LOG_LEVEL=INFO
# App configuration
ENV=DEVELOPMENT
ADMIN_IDS=1000001999,1000002000,1000002001
+6
View File
@@ -0,0 +1,6 @@
* text=auto
*.java text eol=crlf
*.sh text eol=lf
gradlew text eol=lf
+1
View File
@@ -1,4 +1,5 @@
.idea
.env
+19
View File
@@ -0,0 +1,19 @@
FROM amazoncorretto:21.0.5 AS deps
WORKDIR /build
COPY --chmod=0755 gradlew gradlew
COPY gradle/ gradle/
RUN --mount=type=bind,source=build.gradle.kts,target=build.gradle.kts \
--mount=type=cache,target=/root/.gradle \
./gradlew dependencies --no-daemon
FROM deps AS package
WORKDIR /build
COPY ./src src/
RUN --mount=type=bind,source=build.gradle.kts,target=build.gradle.kts \
--mount=type=cache,target=/root/.gradle \
./gradlew shadowJar -x test --no-daemon
RUN cp build/libs/*-all.jar app.jar
FROM amazoncorretto:21.0.5 AS final
COPY --from=package build/app.jar app.jar
ENTRYPOINT [ "sh", "-c", "java ${JAVA_OPTS} -jar app.jar" ]
+12 -5
View File
@@ -1,14 +1,11 @@
plugins {
id("java")
java
id("com.gradleup.shadow") version "8.3.5"
}
group = "com.miti99"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
@@ -35,6 +32,16 @@ dependencies {
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
repositories {
mavenCentral()
}
tasks.test {
useJUnitPlatform()
}
@@ -1,6 +1,8 @@
services:
couchbase:
image: couchbase:community-7.6.2
env_file:
- .env
ports:
- "8091-8097:8091-8097"
- "9123:9123"
+26
View File
@@ -0,0 +1,26 @@
services:
server:
build:
context: .
env_file:
- .env
depends_on:
- couchbase
couchbase:
image: couchbase:community-7.6.2
# env_file:
# - .env
# ports: # Enable these ports if you need
# - "8091-8097:8091-8097"
# - "9123:9123"
# - "11207:11207"
# - "11210:11210"
# - "11280:11280"
# - "18091-18097:18091-18097"
volumes:
- couchbase_data:/opt/couchbase/var
restart: unless-stopped
volumes:
couchbase_data:
@@ -8,8 +8,6 @@ import java.util.Set;
import java.util.stream.Collectors;
public class Config {
public static final Env ENV = Env.valueOf(System.getenv("ENV"));
public static final String COUCHBASE_CONNECTION_STRING =
System.getenv("COUCHBASE_CONNECTION_STRING");
public static final String COUCHBASE_USERNAME = System.getenv("COUCHBASE_USERNAME");
@@ -19,7 +17,7 @@ public class Config {
public static final String TELEGRAM_BOT_TOKEN = System.getenv("TELEGRAM_BOT_TOKEN");
public static final String TELEGRAM_BOT_USERNAME = System.getenv("TELEGRAM_BOT_USERNAME");
public static final Long CREATOR_ID = Long.parseLong(System.getenv("CREATOR_ID"));
public static final Env ENV = Env.valueOf(System.getenv("ENV"));
public static final Set<Long> ADMIN_IDS =
Optional.ofNullable(System.getenv("ADMIN_IDS"))
.map(