Skip to content

Commit

Permalink
Migrate to azure pipelines and build windows image
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslorentz committed Sep 22, 2018
1 parent d239019 commit 574dae8
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*
!caddy
!artifacts
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
caddy
caddy.exe
artifacts
vendor
debug.test
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ ENV HOME /root
WORKDIR /
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ADD caddy /bin/
COPY artifacts/binaries/linux/amd64/caddy /bin/

ENTRYPOINT ["/bin/caddy"]
2 changes: 1 addition & 1 deletion Dockerfile-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ EXPOSE 80 443 2015

RUN apk add --no-cache ca-certificates curl

ADD caddy /bin/
COPY artifacts/binaries/linux/amd64/caddy /bin/

ENTRYPOINT ["/bin/caddy"]
2 changes: 1 addition & 1 deletion Dockerfile-alpine-arm32v6
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ EXPOSE 80 443 2015

COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ADD caddy /bin/
COPY artifacts/binaries/linux/arm32v6/caddy /bin/

ENTRYPOINT ["/bin/caddy"]
2 changes: 1 addition & 1 deletion Dockerfile-arm32v6
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ ENV HOME /root
WORKDIR /
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ADD caddy /bin/
COPY artifacts/binaries/linux/arm32v6/caddy /bin/

ENTRYPOINT ["/bin/caddy"]
8 changes: 8 additions & 0 deletions Dockerfile-nanoserver-1803
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM microsoft/nanoserver:1803
LABEL maintainer "Lucas Lorentz <lucaslorentzlara@hotmail.com>"

EXPOSE 80 443 2015

COPY artifacts/binaries/windows/amd64/caddy.exe "C:\\caddy.exe"

ENTRYPOINT ["C:\\caddy.exe"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CADDY-DOCKER-PROXY [![Build Status](https://travis-ci.org/lucaslorentz/caddy-docker-proxy.svg?branch=master)](https://travis-ci.org/lucaslorentz/caddy-docker-proxy)
# CADDY-DOCKER-PROXY [![Build Status](https://dev.azure.com/lucaslorentzlara/lucaslorentzlara/_apis/build/status/lucaslorentz.caddy-docker-proxy?branchName=master)](https://dev.azure.com/lucaslorentzlara/lucaslorentzlara/_build/latest?definitionId=1)

## Introduction
This plugin enables caddy to be used as a reverse proxy for Docker.
Expand Down
77 changes: 77 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
jobs:
- job: Build_Binaries
pool:
vmImage: 'Ubuntu 16.04'

variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.11' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code

steps:
- bash: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
mv !(gopath) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'
- bash: |
curl https://glide.sh/get | sh
displayName: Install Glide
- bash: ./build.sh
workingDirectory: '$(modulePath)'
env:
ARTIFACTS: '$(Build.ArtifactStagingDirectory)'
displayName: Build

- task: PublishBuildArtifacts@1
inputs:
artifactName: binaries
pathtoPublish: '$(Build.ArtifactStagingDirectory)/binaries'
displayName: 'Publish Artifact'

- job: Build_Images_Linux
dependsOn: Build_Binaries
pool:
vmImage: 'Ubuntu 16.04'
steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifacts'
inputs:
downloadPath: artifacts
artifactName: binaries

- bash: |
./build-images-linux.sh
displayName: 'Build images'
- bash: |
./push-images-linux.sh
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: 'Push images'
- job: Build_Images_Windows
dependsOn: Build_Binaries
pool:
vmImage: 'win1803'
steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifacts'
inputs:
downloadPath: artifacts
artifactName: binaries

- bash: |
./build-images-windows.sh
displayName: 'Build images'
- bash: |
./push-images-windows.sh
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: 'Push images'
9 changes: 9 additions & 0 deletions build-images-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

docker build -t lucaslorentz/caddy-docker-proxy:ci -f Dockerfile .
docker build -t lucaslorentz/caddy-docker-proxy:ci-alpine -f Dockerfile-alpine .

docker build -t lucaslorentz/caddy-docker-proxy:ci-arm32v6 -f Dockerfile-arm32v6 .
docker build -t lucaslorentz/caddy-docker-proxy:ci-alpine-arm32v6 -f Dockerfile-alpine-arm32v6 .
5 changes: 5 additions & 0 deletions build-images-windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -e

docker build -t lucaslorentz/caddy-docker-proxy:ci-nanoserver-1803 -f Dockerfile-nanoserver-1803 .
14 changes: 6 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

set -e

echo ==PARAMETERS==
echo ARTIFACTS: "${ARTIFACTS:=./artifacts}"

glide install

go vet $(glide novendor)
go test -race -v $(glide novendor)

CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o caddy
docker build -t lucaslorentz/caddy-docker-proxy:ci -f Dockerfile .
docker build -t lucaslorentz/caddy-docker-proxy:ci-alpine -f Dockerfile-alpine .
docker image tag lucaslorentz/caddy-docker-proxy:ci-alpine lucaslorentz/caddy-docker-proxy:test

CGO_ENABLED=0 GOARCH=arm GOARM=6 GOOS=linux go build -o caddy
docker build -t lucaslorentz/caddy-docker-proxy:ci-arm32v6 -f Dockerfile-arm32v6 .
docker build -t lucaslorentz/caddy-docker-proxy:ci-alpine-arm32v6 -f Dockerfile-alpine-arm32v6 .
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o ${ARTIFACTS}/binaries/linux/amd64/caddy
CGO_ENABLED=0 GOARCH=arm GOARM=6 GOOS=linux go build -o ${ARTIFACTS}/binaries/linux/arm32v6/caddy
CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -o ${ARTIFACTS}/binaries/windows/amd64/caddy.exe
15 changes: 0 additions & 15 deletions deploy-branch.sh

This file was deleted.

17 changes: 11 additions & 6 deletions deploy-tag.sh → push-images-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

set -e

if [[ "${TRAVIS_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
echo "Deploying version ${TRAVIS_TAG}..."
docker login -u lucaslorentz -p "$DOCKER_PASSWORD"

export PATCH_VERSION=$(echo $TRAVIS_TAG | cut -c2-)
export MINOR_VERSION=$(echo $PATCH_VERSION | cut -d. -f-2)
docker push lucaslorentz/caddy-docker-proxy:ci
docker push lucaslorentz/caddy-docker-proxy:ci-alpine
docker push lucaslorentz/caddy-docker-proxy:ci-arm32v6
docker push lucaslorentz/caddy-docker-proxy:ci-alpine-arm32v6

if [[ "${RELEASE_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
echo "Releasing version ${RELEASE_VERSION}..."

PATCH_VERSION=$(echo $RELEASE_VERSION | cut -c2-)
MINOR_VERSION=$(echo $PATCH_VERSION | cut -d. -f-2)

docker login -u lucaslorentz -p "$DOCKER_PASSWORD"

Expand Down Expand Up @@ -41,6 +48,4 @@ if [[ "${TRAVIS_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
docker push lucaslorentz/caddy-docker-proxy:alpine-arm32v6
docker push lucaslorentz/caddy-docker-proxy:${PATCH_VERSION}-alpine-arm32v6
docker push lucaslorentz/caddy-docker-proxy:${MINOR_VERSION}-alpine-arm32v6
else
echo "Skipping version deploy"
fi
24 changes: 24 additions & 0 deletions push-images-windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -e

docker login -u lucaslorentz -p "%DOCKER_PASSWORD%"

docker push lucaslorentz/caddy-docker-proxy:ci-nanoserver-1803

if [[ "${RELEASE_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
echo "Releasing version ${RELEASE_VERSION}..."

PATCH_VERSION=$(echo $RELEASE_VERSION | cut -c2-)
MINOR_VERSION=$(echo $PATCH_VERSION | cut -d. -f-2)

docker login -u lucaslorentz -p "$DOCKER_PASSWORD"

# nanoserver-1803
docker tag lucaslorentz/caddy-docker-proxy:ci-nanoserver-1803 lucaslorentz/caddy-docker-proxy:nanoserver-1803
docker tag lucaslorentz/caddy-docker-proxy:ci-nanoserver-1803 lucaslorentz/caddy-docker-proxy:${PATCH_VERSION}-nanoserver-1803
docker tag lucaslorentz/caddy-docker-proxy:ci-nanoserver-1803 lucaslorentz/caddy-docker-proxy:${MINOR_VERSION}-nanoserver-1803
docker push lucaslorentz/caddy-docker-proxy:nanoserver-1803
docker push lucaslorentz/caddy-docker-proxy:${PATCH_VERSION}-nanoserver-1803
docker push lucaslorentz/caddy-docker-proxy:${MINOR_VERSION}-nanoserver-1803
fi

0 comments on commit 574dae8

Please sign in to comment.