-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
148 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM mhart/alpine-node:5.7.1 | ||
FROM mhart/alpine-node:10 | ||
|
||
VOLUME /tmp | ||
RUN npm install -g spa-http-server | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM mhart/alpine-node:10 AS NODE | ||
|
||
WORKDIR /tmp/ | ||
COPY package*.json ./ | ||
RUN npm install | ||
RUN npm install -g spa-http-server | ||
COPY . . | ||
RUN npm run build | ||
|
||
FROM NODE | ||
COPY --from=NODE /tmp/dist /opt/www | ||
COPY --from=NODE /tmp/run.sh /opt/run.sh | ||
ARG VUE_APP_API_HOST | ||
ENV VUE_APP_API_HOST=$VUE_APP_API_HOST | ||
EXPOSE 8080 | ||
ENTRYPOINT ["sh","/opt/run.sh" ] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Deploy to Azure Kubernetes Service | ||
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service | ||
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker | ||
|
||
trigger: | ||
- master | ||
|
||
resources: | ||
- repo: self | ||
|
||
variables: | ||
|
||
# Container registry service connection established during pipeline creation | ||
dockerRegistryServiceConnection: 'c860058c-3e50-4801-8650-cd6be9406172' | ||
imageRepository: 'ui' | ||
containerRegistry: 'myeventstormingregistry.azurecr.io' | ||
dockerfilePath: '**/DockerfileAutoBuild' | ||
tag: '$(Build.BuildId)' | ||
imagePullSecret: 'myeventstormingregistry4a7e-auth' | ||
|
||
# Agent VM image name | ||
vmImageName: 'ubuntu-latest' | ||
|
||
# Name of the new namespace being created to deploy the PR changes. | ||
k8sNamespaceForPR: '$(system.pullRequest.sourceBranch)' | ||
|
||
stages: | ||
- stage: Build | ||
displayName: Build 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) | ||
- upload: manifests | ||
artifact: manifests | ||
|
||
- stage: Deploy | ||
displayName: Deploy stage | ||
# dependsOn: Build | ||
|
||
jobs: | ||
- deployment: Deploy | ||
# condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))) | ||
displayName: Deploy | ||
pool: | ||
vmImage: $(vmImageName) | ||
environment: 'kimscottui.default' | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- task: Kubernetes@1 | ||
displayName: 'Get gatewayIp' | ||
name: 'gatewayip' | ||
continueOnError: true | ||
inputs: | ||
connectionType: 'Kubernetes Service Connection' | ||
namespace: 'default' | ||
command: 'get' | ||
arguments: "svc gateway --ignore-not-found" | ||
secretType: 'dockerRegistry' | ||
containerRegistryType: 'Azure Container Registry' | ||
outputFormat: "jsonpath='{.status.loadBalancer.ingress[0].ip}'" | ||
- task: Kubernetes@1 | ||
displayName: 'Get gateway port' | ||
name: 'gatewayport' | ||
continueOnError: true | ||
inputs: | ||
connectionType: 'Kubernetes Service Connection' | ||
namespace: 'default' | ||
command: 'get' | ||
arguments: "svc gateway --ignore-not-found" | ||
secretType: 'dockerRegistry' | ||
containerRegistryType: 'Azure Container Registry' | ||
outputFormat: "jsonpath='{.spec.ports[0].port}'" | ||
- task: Kubernetes@1 | ||
inputs: | ||
connectionType: 'Kubernetes Service Connection' | ||
namespace: 'default' | ||
command: 'apply' | ||
useConfigurationFile: true | ||
configurationType: 'inline' | ||
inline: | | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: $(imageRepository) | ||
labels: | ||
app: $(imageRepository) | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: $(imageRepository) | ||
template: | ||
metadata: | ||
labels: | ||
app: $(imageRepository) | ||
spec: | ||
containers: | ||
- name: $(imageRepository) | ||
image: $(containerRegistry)/$(imageRepository):$(tag) | ||
ports: | ||
- containerPort: 8080 | ||
env: | ||
- name: VUE_APP_API_HOST | ||
value: http://$(gatewayip.KubectlOutput):$(gatewayport.KubectlOutput) | ||
secretType: 'dockerRegistry' | ||
containerRegistryType: 'Azure Container Registry' | ||
- task: KubernetesManifest@0 | ||
displayName: Deploy to Kubernetes cluster | ||
inputs: | ||
action: deploy | ||
manifests: | | ||
$(Pipeline.Workspace)/manifests/service.yml | ||
imagePullSecrets: | | ||
$(imagePullSecret) | ||
containers: | | ||
$(containerRegistry)/$(imageRepository):$(tag) |