Skip to content

Commit

Permalink
DV-000303: Add map location real time.
Browse files Browse the repository at this point in the history
  • Loading branch information
vaskocuturilo committed Aug 21, 2024
1 parent a90ac65 commit 617d016
Show file tree
Hide file tree
Showing 12 changed files with 657 additions and 346 deletions.
44 changes: 11 additions & 33 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,31 @@
# Stage 1: Build
FROM gradle:7.4.2-jdk-alpine AS TEMP_BUILD_IMAGE

# Install dependencies in a single layer
# Install dependencies
RUN apk add --no-cache bash \
&& echo "@personal https://dl-cdn.alpinelinux.org/alpine/v3.9/main" >> /etc/apk/repositories \
&& echo "@personal https://dl-cdn.alpinelinux.org/alpine/v3.15/main" >> /etc/apk/repositories \
&& apk add --no-cache nodejs@personal npm@personal \
&& node --version \
&& npm --version

# Set the working directory
WORKDIR /usr/app/
ENV APP_HOME=/usr/app/

# Copy only necessary files for dependency resolution and building
COPY build.gradle settings.gradle ./
COPY gradle ./gradle

# Ensure Gradle runs as non-root user
RUN chown -R gradle:gradle ./

USER gradle
WORKDIR $APP_HOME
COPY build.gradle settings.gradle $APP_HOME

# Build the application, skipping tests for faster builds
ARG REACT_APP_TOKEN
ENV REACT_APP_TOKEN $REACT_APP_TOKEN
COPY gradle $APP_HOME/gradle/
COPY --chown=gradle:gradle . /home/gradle/src

COPY . .
RUN gradle clean npm_run_build copyTask build -x test --no-daemon || return 0

# Stage 2: Package
FROM eclipse-temurin:21-jdk-alpine

# Add curl (if needed) in a single command to minimize layers
FROM eclipse-temurin:17-jdk-alpine
RUN apk --no-cache add curl

# Define environment variables
ENV ARTIFACT_NAME=simpleRegions-0.0.1-SNAPSHOT.jar
ENV APP_HOME=/usr/app

# Set the working directory
WORKDIR $APP_HOME

# Copy the built artifact from the build stage
COPY --from=TEMP_BUILD_IMAGE /usr/app/build/libs/$ARTIFACT_NAME app.jar

# Use a non-root user to run the application
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/build/libs/$ARTIFACT_NAME app.jar

# Expose the application's port
EXPOSE 8080

# Set the entry point to run the jar
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=docker", "/app.jar"]
ENTRYPOINT ["java", "-jar","-Dspring.profiles.active=docker", "/app.jar"]
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ services:
hostname: server-regions
container_name: server-regions
image: myapp
environment:
- REACT_APP_TOKEN=${REACT_APP_TOKEN}
restart: always
logging:
#limit logs to 200MB (4rotations of 50M each)
Expand All @@ -40,10 +42,11 @@ services:
build:
context: .
dockerfile: ./Dockerfile
args:
REACT_APP_TOKEN: abc123
ports:
- "8080:8080"
- "8090:8090"
env_file:
- frontend/.env

healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:8090/actuator/health" ]
Expand Down
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
.env.development.local
.env.test.local
.env.production.local
.env

npm-debug.log*
yarn-debug.log*
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM node:20-alpine

WORKDIR /usr/src/app

COPY package.json ./
COPY package*.json ./

RUN npm install

Expand Down
Loading

0 comments on commit 617d016

Please sign in to comment.