eleeter commited on
Commit
d08f75d
·
verified ·
1 Parent(s): 84b8e15

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -8
Dockerfile CHANGED
@@ -1,27 +1,29 @@
1
  # STEP 1: Build stage
2
  FROM gradle:8-jdk17 AS build
3
  WORKDIR /home/gradle/src
4
- # Copy everything and build
 
5
  COPY --chown=gradle:gradle . .
6
- # This runs your custom 'jar' task from build.gradle
 
7
  RUN gradle jar --no-daemon
8
 
9
  # STEP 2: Runtime stage
10
  FROM eclipse-temurin:17-jre
11
  WORKDIR /app
12
 
13
- # Copy the JAR. Your build.gradle creates 'eleeter-1.0.jar' (group + version)
14
- # or similar. Using *.jar is safer.
15
  COPY --from=build /home/gradle/src/build/libs/*.jar app.jar
16
 
 
17
  COPY *.json .
18
 
19
- RUN echo "hosts: files dns" > /etc/nsswitch.conf
20
-
21
 
22
- # Give permissions and expose port
23
  RUN chmod -R 777 /app
24
  EXPOSE 8000
25
 
26
- # Start Java directly
27
  ENTRYPOINT ["java", "-Dsun.net.inetaddr.ttl=0", "-Dsun.net.inetaddr.negative.ttl=0", "-jar", "app.jar"]
 
1
  # STEP 1: Build stage
2
  FROM gradle:8-jdk17 AS build
3
  WORKDIR /home/gradle/src
4
+
5
+ # Copy all project files
6
  COPY --chown=gradle:gradle . .
7
+
8
+ # Run the 'jar' task defined in your build.gradle
9
  RUN gradle jar --no-daemon
10
 
11
  # STEP 2: Runtime stage
12
  FROM eclipse-temurin:17-jre
13
  WORKDIR /app
14
 
15
+ # 1. Copy the JAR from the build stage
 
16
  COPY --from=build /home/gradle/src/build/libs/*.jar app.jar
17
 
18
+ # 2. Copy your JSON configuration files
19
  COPY *.json .
20
 
21
+ # 3. FIX DNS: Force the container to use Google's DNS
22
+ RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf
23
 
24
+ # 4. Set permissions
25
  RUN chmod -R 777 /app
26
  EXPOSE 8000
27
 
28
+ # 5. Start Java with DNS caching disabled to prevent "UnknownHost" sticking
29
  ENTRYPOINT ["java", "-Dsun.net.inetaddr.ttl=0", "-Dsun.net.inetaddr.negative.ttl=0", "-jar", "app.jar"]