Created
October 10, 2024 05:51
-
-
Save unclebean/303dbc7268853ea93a9972f39711bc23 to your computer and use it in GitHub Desktop.
docker for AKS deployment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spec: | |
containers: | |
- name: your-app | |
image: your-app:dev | |
ports: | |
- containerPort: 8080 | |
env: | |
- name: SPRING_PROFILES_ACTIVE | |
value: "dev" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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