Skip to content

Instantly share code, notes, and snippets.

@unclebean
Created October 10, 2024 05:51
Show Gist options
  • Save unclebean/303dbc7268853ea93a9972f39711bc23 to your computer and use it in GitHub Desktop.
Save unclebean/303dbc7268853ea93a9972f39711bc23 to your computer and use it in GitHub Desktop.
docker for AKS deployment
spec:
containers:
- name: your-app
image: your-app:dev
ports:
- containerPort: 8080
env:
- name: SPRING_PROFILES_ACTIVE
value: "dev"
# Build image for dev environment
docker build --build-arg SPRING_PROFILES_ACTIVE=dev -t your-app:dev .
# Build image for staging environment
docker build --build-arg SPRING_PROFILES_ACTIVE=staging -t your-app:staging .
# Build image for production environment
docker build --build-arg SPRING_PROFILES_ACTIVE=prod -t your-app:prod .
# Use a base image with JDK installed
FROM openjdk:17-jdk-slim
# Set the working directory
WORKDIR /app
# Copy the jar file from the target directory (after the build)
COPY target/your-app.jar app.jar
# Expose the default Spring Boot port
EXPOSE 8080
# Entry point for running the app, passing the active profile as an environment variable
ENTRYPOINT ["java", "-Dspring.profiles.active=${SPRING_PROFILES_ACTIVE}", "-jar", "app.jar"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment