-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (56 loc) · 2.12 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (56 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Build stage
FROM maven:3.9.6-eclipse-temurin-17 AS build
WORKDIR /app
COPY . .
RUN mvn clean package -DskipTests
# Runtime stage
# Za najvecu stabilnost u buducnosti koristite fiksiranu verziju
# FROM eclipse-temurin:17.0.9_9-jre-slim
FROM eclipse-temurin:17.0.9_9-jre-alpine
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
# Explicitly copy DB file
COPY cycling_power.db /app/cycling_power.db
# Copy the entire json folder
COPY json /app/json
COPY images /app/images
RUN mkdir -p /app/Uploads && chmod -R 755 /app
RUN chmod -R 644 /app/json /app/images && chmod 664 /app/cycling_power.db
RUN ls -l /app/cycling_power.db || echo "DB file not found"
RUN ls -l /app/json || echo "json folder not found"
# za eclipse-temurin:17.0.9_9-jre-slim
# RUN apt-get update && apt-get install -y git
# za alpine
RUN apk update && apk add git
RUN git config --global user.email "java4now@gmail.com" && \
git config --global user.name "CyclingPower_Server"
ARG GIT_TOKEN
RUN if [ -n "$GIT_TOKEN" ]; then \
git clone https://x:${GIT_TOKEN}@github.com/CommonGrounds/CyclingPower_Server.git /app/repo && \
mv /app/repo/.git /app/.git && \
rm -rf /app/repo; \
else \
echo "GIT_TOKEN not provided, skipping clone"; \
fi
ENV SPRING_PROFILES_ACTIVE=prod
ENV SERVER_ADDRESS=0.0.0.0
ENV PORT=10000
# Expose the port
EXPOSE ${PORT}
# ENTRYPOINT ["java", "-Dserver.port=${PORT:8080}", "-jar", "app.jar"]
ENTRYPOINT ["java", "-jar", "app.jar"]
# Pokrenuti docker service -
# sudo systemctl start docker
# ili
# sudo dockerd
# Novi terminal, build pa run -
# sudo docker build -t app .
# docker run --rm -it app
# sudo docker run -p 8080:8080 app
# odnosno realna ( prema ovoj konfiguraciji ) lokalna provera
# docker run -p 8080:10000 -e SPRING_PROFILES_ACTIVE=prod -e PORT=10000 app
# ili
# docker run -p 8080:10000 --rm -it app
# --rm: (Preporučeno) Automatski briše kontejner kada ga zaustavite.
# -it: (Preporučeno) Pokreće kontejner u interaktivnom režimu, što omogućava da vidite logove u realnom vremenu i da ga zaustavite sa Ctrl+C.
# sa http://localhost:8080/ treba da vrati - Server is running - Mon Oct 13 10:21:53 UTC 2025