diff --git a/Dockerfile.txt b/Dockerfile.txt new file mode 100644 index 00000000..88e7d2ec --- /dev/null +++ b/Dockerfile.txt @@ -0,0 +1,29 @@ +# Docker multi-stage build + +# 1. Building the App with Maven +FROM maven:3-jdk-11 + +ADD . /springbootvuejs +WORKDIR /springbootvuejs + +# Just echo so we can see, if everything is there :) +RUN ls -l + +# Run Maven build +RUN mvn clean install + + +# Just using the build artifact and then removing the build-container +FROM openjdk:17.0.2-jdk + +MAINTAINER Jonas Hecht + +VOLUME /tmp + +# Add Spring Boot app.jar to Container +COPY --from=0 "/springbootvuejs/backend/target/backend-0.0.1-SNAPSHOT.jar" app.jar + +ENV JAVA_OPTS="" + +# Fire up our Spring Boot app by default +ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ] \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..f5572a37 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,39 @@ +# Docker +# Build and push an image to Azure Container Registry +# https://docs.microsoft.com/azure/devops/pipelines/languages/docker + +trigger: +- vue-cli-v2-webpack-v3 + +resources: +- repo: self + +variables: + # Container registry service connection established during pipeline creation + dockerRegistryServiceConnection: '1a082f41-08de-470a-9c82-3822b1fb153d' + imageRepository: 'dagreatjhspringbootvuejs' + containerRegistry: 'igmcr.azurecr.io' + dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile.txt' + tag: '$(Build.BuildId)' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + +stages: +- stage: Build + displayName: Build and push stage + jobs: + - job: Build + displayName: Build + pool: + vmImage: $(vmImageName) + steps: + - task: Docker@2 + displayName: Build and push an image to container registry + inputs: + command: buildAndPush + repository: $(imageRepository) + dockerfile: $(dockerfilePath) + containerRegistry: $(dockerRegistryServiceConnection) + tags: | + $(tag)