Skip to content

Commit 7de0968

Browse files
authored
Merge pull request #9 from resilientbd/feature/add-docker-support
Add Docker Support with Dockerfile and Docker Compose
2 parents 0981a90 + 84b45ff commit 7de0968

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

previews/docker-console-1.png

403 KB
Loading

previews/docker-console-2.png

262 KB
Loading

webrtc-backend/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Use the official Gradle 6.6.1 image with JDK 17 as the build environment
2+
FROM gradle:6.6.1-jdk11 AS build
3+
4+
# Set the working directory inside the container
5+
WORKDIR /app
6+
7+
# Copy the project files into the container
8+
COPY . .
9+
10+
# Set JVM compatibility to 17 in the build process
11+
RUN gradle clean build -Dorg.gradle.java.home=/opt/java/openjdk -x test --no-daemon
12+
13+
# Use the official OpenJDK 17 runtime as the runtime environment
14+
FROM openjdk:17-jdk-slim
15+
16+
# Set the working directory inside the container
17+
WORKDIR /app
18+
19+
# Copy the built JAR from the build environment
20+
COPY --from=build /app/build/libs/*.jar app.jar
21+
22+
# Expose the port that the application will run on
23+
EXPOSE 8080
24+
25+
# Set environment variables if needed (e.g., for ports)
26+
ENV PORT=8080
27+
28+
# Run the application
29+
CMD ["java", "-jar", "app.jar"]

webrtc-backend/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,18 @@ dependencies {
4141
implementation "io.ktor:ktor-client-logging-jvm:$ktor_version"
4242
testImplementation "io.ktor:ktor-server-tests:$ktor_version"
4343
}
44+
45+
// JAR task configuration to include the main class in the manifest
46+
jar {
47+
manifest {
48+
attributes(
49+
'Main-Class': mainClassName, // Sets the Main-Class attribute for JAR execution
50+
'Implementation-Title': project.name,
51+
'Implementation-Version': project.version
52+
)
53+
}
54+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE // Exclude duplicate files
55+
from {
56+
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } // Include dependencies in the JAR
57+
}
58+
}

webrtc-backend/docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: '3.8'
2+
3+
services:
4+
webrtc_ktro_server:
5+
# image: DOCKER IMAGE NAME
6+
build: .
7+
ports:
8+
- "8080:8080"
9+
restart: always

0 commit comments

Comments
 (0)