diff --git a/ES.SFTP.Host/Dockerfile b/ES.SFTP.Host/Dockerfile index 893650f..4b5af81 100644 --- a/ES.SFTP.Host/Dockerfile +++ b/ES.SFTP.Host/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base RUN apt-get update && \ # - Install required packages # @@ -21,7 +21,7 @@ RUN apt-get update && \ WORKDIR /app EXPOSE 22 80 -FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build +FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build WORKDIR /src COPY ["ES.SFTP.Host/ES.SFTP.Host.csproj", "ES.SFTP.Host/"] RUN dotnet restore "ES.SFTP.Host/ES.SFTP.Host.csproj" diff --git a/ES.SFTP.Host/ES.SFTP.Host.csproj b/ES.SFTP.Host/ES.SFTP.Host.csproj index 102d47c..0f3cdb5 100644 --- a/ES.SFTP.Host/ES.SFTP.Host.csproj +++ b/ES.SFTP.Host/ES.SFTP.Host.csproj @@ -13,7 +13,9 @@ - + + PreserveNewest + diff --git a/README.md b/README.md index c3985bd..832ae95 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ Below are deployment methods for: - Docker CLI - Docker-Compose - Kubernetes using Helm (recommended for Kubernetes) -- Kubernetes (manual) Process: 1) Create server configuration @@ -147,13 +146,6 @@ You can customize the values of the helm deployment by using the following Value > Find us on [Helm Hub](https://hub.helm.sh/charts/emberstack) -### Deployment to Kubernetes using kubectl -Each release (found on the [Releases](https://github.com/EmberStack/docker-sftp/releases) GitHub page) contains the manual deployment file (`sftp.yaml`). - -```shellsession -$ kubectl apply -f https://github.com/EmberStack/docker-sftp/releases/latest/download/sftp.yaml -``` - ## Advanced Configuration TODO: This section is under development due to the number of configuration options being added. Please open an issue on the [emberstack/docker-sftp](https://github.com/emberstack/docker-sftp) project if you need help. diff --git a/azure-pipelines.yaml b/azure-pipelines.yaml index 3dd62b1..4044c84 100644 --- a/azure-pipelines.yaml +++ b/azure-pipelines.yaml @@ -1,7 +1,7 @@ -name: $(coreVersion).$(Date:yy)$(DayOfYear).$(Rev:r) +name: $(version).$(Rev:r) variables: - coreVersion: 1 + version: 1.1 buildConfiguration: "Release" imageRepository: "emberstack/sftp" DOCKER_CLI_EXPERIMENTAL: 'enabled' @@ -12,69 +12,129 @@ trigger: - "*" stages: - + - stage: build displayName: "Build" jobs: - - job: build - displayName: "Build Job" + + - job: build_helm + displayName: "Helm" pool: vmImage: "Ubuntu-16.04" steps: + - script: | mkdir -p artifacts/helm - mkdir -p artifacts/kubectl workingDirectory: '$(Build.ArtifactStagingDirectory)' displayName: 'Create Artifacts directories' - task: HelmInstaller@1 - displayName: 'Install Helm' - inputs: - helmVersionToInstall: 2.14.1 - - - script: 'helm lint' - workingDirectory: deploy/helm/sftp - displayName: 'helm lint' - - - task: HelmDeploy@0 - displayName: 'helm package' inputs: - connectionType: None - command: package - chartPath: deploy/helm/sftp - chartVersion: '$(Build.BuildNumber)' - destination: '$(Build.ArtifactStagingDirectory)/artifacts/helm' + helmVersionToInstall: 'latest' - - script: 'helm template --name sftp sftp > $(Build.ArtifactStagingDirectory)/artifacts/kubectl/sftp-$(Build.BuildNumber).yaml' - workingDirectory: deploy/helm - displayName: 'helm template' + - script: | + helm package --destination $(Build.ArtifactStagingDirectory)/artifacts/helm --version $(Build.BuildNumber) --app-version $(Build.BuildNumber) deploy/helm/sftp + displayName: 'Helm Package' - publish: '$(Build.ArtifactStagingDirectory)/artifacts/helm' artifact: 'helm' - displayName: 'Publish helm artifact' - - publish: '$(Build.ArtifactStagingDirectory)/artifacts/kubectl' - artifact: 'kubectl' - displayName: 'Publish kubectl artifact' + + + - job: build_docker_arm32 + displayName: "Docker arm32" + pool: + name: winromulus + demands: + - Agent.OSArchitecture -equals ARM + steps: + + - script: | + apt-get update + apt-get install \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg2 \ + software-properties-common + curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - + add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/debian \ + $(lsb_release -cs) \ + stable" + apt-get update + apt-get install docker-ce docker-ce-cli containerd.io + displayName: 'Install docker' + + - task: Docker@2 + displayName: 'Build arm32 image' + inputs: + containerRegistry: 'Emberstack Docker Hub' + repository: $(imageRepository) + Dockerfile: ES.SFTP.Host/Dockerfile + command: build + buildContext: . + tags: 'build-$(Build.BuildNumber)-arm32' + + - task: Docker@2 + displayName: "Push image" + inputs: + containerRegistry: "Emberstack Docker Hub" + repository: $(imageRepository) + command: push + tags: | + build-$(Build.BuildNumber)-arm32 + + + - job: build_docker_amd64 + displayName: "Docker amd64" + pool: + vmImage: "Ubuntu-16.04" + steps: + + - task: DockerInstaller@0 + displayName: 'Install docker' + inputs: + dockerVersion: '19.03.5' - task: Docker@2 - displayName: "Build amd64 image" + displayName: 'Build amd64 image' inputs: - containerRegistry: "Emberstack Docker Hub" + containerRegistry: 'Emberstack Docker Hub' repository: $(imageRepository) Dockerfile: ES.SFTP.Host/Dockerfile command: build buildContext: . - tags: "build-$(Build.BuildNumber)-amd64" + tags: 'build-$(Build.BuildNumber)-amd64' - task: Docker@2 - displayName: "Push images" + displayName: "Push image" inputs: containerRegistry: "Emberstack Docker Hub" repository: $(imageRepository) command: push tags: | build-$(Build.BuildNumber)-amd64 + + + - job: build_docker_multiarch + displayName: "Docker multiarch" + pool: + vmImage: "Ubuntu-16.04" + dependsOn: + - build_docker_amd64 + steps: + + - task: DockerInstaller@0 + displayName: 'Install docker' + inputs: + dockerVersion: '19.03.5' + + - task: Docker@2 + displayName: "Docker Hub Login" + inputs: + containerRegistry: "Emberstack Docker Hub" + command: login - task: Docker@2 displayName: "Docker Hub Login" @@ -83,12 +143,14 @@ stages: command: login - script: | - docker manifest create $(imageRepository):build-$(Build.BuildNumber) $(imageRepository):build-$(Build.BuildNumber)-amd64 + docker manifest create $(imageRepository):build-$(Build.BuildNumber) $(imageRepository):build-$(Build.BuildNumber)-amd64 $(imageRepository):build-$(Build.BuildNumber)-arm32 docker manifest inspect $(imageRepository):build-$(Build.BuildNumber) docker manifest push $(imageRepository):build-$(Build.BuildNumber) displayName: "Create and push multi-arch manifest" + + - stage: release displayName: "Release" dependsOn: 'build' @@ -101,13 +163,11 @@ stages: variables: - group: "OpenSource.GitHub" steps: - - checkout: none - - download: current - artifact: 'helm' + - checkout: none - download: current - artifact: 'kubectl' + artifact: 'helm' - task: Docker@2 displayName: "Docker Login" @@ -115,17 +175,16 @@ stages: containerRegistry: "Emberstack Docker Hub" command: login - - task: HelmInstaller@0 - displayName: 'Install Helm' + - task: HelmInstaller@1 inputs: - helmVersion: 2.13.1 - kubectlVersion: 1.10.11 + helmVersionToInstall: 'latest' - script: | docker pull $(imageRepository):build-$(Build.BuildNumber)-amd64 - docker manifest create $(imageRepository):release-$(Build.BuildNumber) $(imageRepository):build-$(Build.BuildNumber)-amd64 - docker manifest push $(imageRepository):release-$(Build.BuildNumber) - docker manifest create $(imageRepository):latest $(imageRepository):build-$(Build.BuildNumber)-amd64 + docker pull $(imageRepository):build-$(Build.BuildNumber)-arm32 + docker manifest create $(imageRepository):$(Build.BuildNumber) $(imageRepository):build-$(Build.BuildNumber)-amd64 $(imageRepository):build-$(Build.BuildNumber)-arm32 + docker manifest create $(imageRepository):latest $(imageRepository):build-$(Build.BuildNumber)-amd64 $(imageRepository):build-$(Build.BuildNumber)-arm32 + docker manifest push $(imageRepository):$(Build.BuildNumber) docker manifest push $(imageRepository):latest displayName: 'docker pull, tag and push' @@ -144,12 +203,7 @@ stages: git status git commit -m "Added sftp-$(Build.BuildNumber).tgz" git push - displayName: 'Add chart to GitHub repository' - - - script: | - mkdir -p github - cp $(Pipeline.Workspace)/kubectl/sftp-$(Build.BuildNumber).yaml github/sftp.yaml - displayName: 'Prepare GitHub Artifacts' + displayName: 'Add chart to GitHub repository' - task: GitHubRelease@1 displayName: 'GitHub release (create)' @@ -161,5 +215,4 @@ stages: title: 'Release v$(Build.BuildNumber)' releaseNotesSource: inline releaseNotes: 'The release process is automated.' - assets: '$(System.DefaultWorkingDirectory)/github/*.*' \ No newline at end of file diff --git a/deploy/helm/sftp/templates/deployment.yaml b/deploy/helm/sftp/templates/deployment.yaml index 00f39d7..b08a0d8 100644 --- a/deploy/helm/sftp/templates/deployment.yaml +++ b/deploy/helm/sftp/templates/deployment.yaml @@ -26,7 +26,11 @@ spec: {{- end }} containers: - name: {{ .Chart.Name }} + {{- if .Values.image.tag }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + {{- else }} + image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}" + {{- end }} imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: ssh diff --git a/deploy/helm/sftp/templates/service.yaml b/deploy/helm/sftp/templates/service.yaml index a82d87a..ebe6b53 100644 --- a/deploy/helm/sftp/templates/service.yaml +++ b/deploy/helm/sftp/templates/service.yaml @@ -10,8 +10,10 @@ metadata: {{- end }} spec: {{- if ne .Values.service.type "NodePort" }} +{{- if .Values.service.clusterIP }} clusterIP: "{{ .Values.service.clusterIP }}" {{- end }} +{{- end }} {{- if .Values.service.externalIPs }} externalIPs: {{ toYaml .Values.service.externalIPs | indent 4 }} diff --git a/deploy/helm/sftp/values.yaml b/deploy/helm/sftp/values.yaml index 9e56597..51333e5 100644 --- a/deploy/helm/sftp/values.yaml +++ b/deploy/helm/sftp/values.yaml @@ -6,7 +6,7 @@ replicaCount: 1 image: repository: emberstack/sftp - tag: latest + tag: "" pullPolicy: Always imagePullSecrets: []