Skip to content

Commit

Permalink
ui deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
kimscott committed Jan 28, 2020
1 parent 4bcdf33 commit b15dba2
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
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
Expand Down
16 changes: 16 additions & 0 deletions DockerfileAutoBuild
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" ]
131 changes: 131 additions & 0 deletions azure-pipelines-with-gateway.yaml
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)

0 comments on commit b15dba2

Please sign in to comment.