mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
Utilise Buildkite for Authelia CI/CD (#507)
Publish steps are currently disabled.
This commit is contained in:
parent
511b0b3c62
commit
2fb20882d9
17
.buildkite/hooks/post-checkout
Executable file
17
.buildkite/hooks/post-checkout
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
set +u
|
||||
|
||||
if [[ ! $BUILDKITE_COMMAND =~ "buildkite-agent pipeline upload" ]];
|
||||
then
|
||||
echo "--- :buildkite: Setting up Build environment"
|
||||
source bootstrap.sh
|
||||
if [[ $BUILDKITE_COMMAND == "authelia-scripts --log-level debug ci" ]];
|
||||
then
|
||||
go mod download
|
||||
fi
|
||||
if [[ $BUILDKITE_LABEL =~ ":selenium:" ]];
|
||||
then
|
||||
go mod download
|
||||
fi
|
||||
fi
|
13
.buildkite/hooks/post-command
Executable file
13
.buildkite/hooks/post-command
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
set +u
|
||||
|
||||
if [[ $BUILDKITE_LABEL =~ ":selenium:" ]] || [[ $BUILDKITE_LABEL =~ ":docker: Build Image" ]];
|
||||
then
|
||||
CONTAINERS=$(docker ps -a -q)
|
||||
if [[ $CONTAINERS != "" ]];
|
||||
then
|
||||
echo "--- :docker: Clean environment"
|
||||
docker rm -f $CONTAINERS
|
||||
fi
|
||||
fi
|
25
.buildkite/hooks/pre-artifact
Executable file
25
.buildkite/hooks/pre-artifact
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
set +u
|
||||
|
||||
DOCKER_IMAGE=authelia/authelia
|
||||
|
||||
if [[ $BUILDKITE_COMMAND == "authelia-scripts --log-level debug ci" ]];
|
||||
then
|
||||
tar -czf dist.tar.gz dist
|
||||
tar -czf web.tar.gz web
|
||||
fi
|
||||
|
||||
if [[ $BUILDKITE_LABEL =~ ":docker: Build Image" ]];
|
||||
then
|
||||
echo "--- :docker: Saving artifacts for :buildkite: :docker: :github: releases"
|
||||
# Save binary for buildkite and github artifacts
|
||||
docker create --name authelia-binary $DOCKER_IMAGE:latest
|
||||
docker cp authelia-binary:/usr/app/authelia ./authelia-linux-$ARCH
|
||||
docker cp authelia-binary:/usr/app/public_html ./
|
||||
docker rm -f authelia-binary
|
||||
tar -czf authelia-linux-$ARCH.tar.gz authelia-linux-$ARCH public_html
|
||||
sha256sum authelia-linux-$ARCH.tar.gz > authelia-linux-$ARCH.tar.gz.sha256
|
||||
# Saving image for push to DockerHub
|
||||
docker save $DOCKER_IMAGE | gzip > authelia-image-$ARCH.tar.gz
|
||||
fi
|
21
.buildkite/hooks/pre-command
Executable file
21
.buildkite/hooks/pre-command
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
set +u
|
||||
|
||||
if [[ $BUILDKITE_LABEL =~ ":selenium:" ]];
|
||||
then
|
||||
echo "--- :go::node: Extracting build artifacts"
|
||||
buildkite-agent artifact download "dist.tar.gz" . && tar xf dist.tar.gz
|
||||
buildkite-agent artifact download "web.tar.gz" . && tar xf web.tar.gz
|
||||
fi
|
||||
|
||||
if [[ $BUILDKITE_LABEL =~ ":docker: Deploy Image" ]];
|
||||
then
|
||||
buildkite-agent artifact download "authelia-image-$ARCH*" .
|
||||
zcat authelia-image-$ARCH.tar.gz | docker load
|
||||
fi
|
||||
|
||||
if [[ $BUILDKITE_LABEL == ":github: Deploy Artifacts" ]];
|
||||
then
|
||||
buildkite-agent artifact download "authelia-linux-*" .
|
||||
fi
|
48
.buildkite/pipeline.yml
Normal file
48
.buildkite/pipeline.yml
Normal file
|
@ -0,0 +1,48 @@
|
|||
steps:
|
||||
- label: ":hammer_and_wrench: Build & Test"
|
||||
command: "authelia-scripts --log-level debug ci"
|
||||
agents:
|
||||
upload: "fast"
|
||||
artifact_paths:
|
||||
- "dist.tar.gz"
|
||||
- "web.tar.gz"
|
||||
key: "build"
|
||||
|
||||
- wait
|
||||
|
||||
- label: ":chrome: Integration Tests"
|
||||
command: ".buildkite/steps/e2etests.sh | buildkite-agent pipeline upload"
|
||||
key: "test"
|
||||
|
||||
- wait
|
||||
|
||||
- label: ":docker: Image Builds"
|
||||
command: ".buildkite/steps/buildimages.sh | buildkite-agent pipeline upload"
|
||||
branches: "master v*"
|
||||
depends_on:
|
||||
- "build"
|
||||
key: "build-docker"
|
||||
|
||||
# - wait
|
||||
#
|
||||
# - label: ":docker: Image Deployments"
|
||||
# command: ".buildkite/steps/deployimages.sh | buildkite-agent pipeline upload"
|
||||
# branches: "master v*"
|
||||
# depends_on:
|
||||
# - "test"
|
||||
# - "build-docker"
|
||||
#
|
||||
# - wait
|
||||
#
|
||||
# - label: ":docker: Deploy Manifests"
|
||||
# command: "authelia-scripts docker push-manifest"
|
||||
# branches: "master v*"
|
||||
# env:
|
||||
# DOCKER_CLI_EXPERIMENTAL: "enabled"
|
||||
#
|
||||
# - label: ":github: Deploy Artifacts"
|
||||
# command: ".buildkite/steps/ghartifacts.sh"
|
||||
# agents:
|
||||
# upload: "fast"
|
||||
# depends_on: "build-docker"
|
||||
# if: build.tag != null
|
15
.buildkite/steps/buildimages.sh
Executable file
15
.buildkite/steps/buildimages.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
for BUILD_ARCH in amd64 arm32v7 arm64v8;
|
||||
do
|
||||
echo " - label: \":docker: Build Image [${BUILD_ARCH}]\""
|
||||
echo " commands:"
|
||||
echo " - \"authelia-scripts docker build --arch=${BUILD_ARCH}\""
|
||||
echo " artifact_paths:"
|
||||
echo " - \"authelia-image-${BUILD_ARCH}.tar.gz\""
|
||||
echo " - \"authelia-linux-${BUILD_ARCH}.tar.gz\""
|
||||
echo " - \"authelia-linux-${BUILD_ARCH}.tar.gz.sha256\""
|
||||
echo " env:"
|
||||
echo " "ARCH: ${BUILD_ARCH}""
|
||||
done
|
13
.buildkite/steps/deployimages.sh
Executable file
13
.buildkite/steps/deployimages.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
for BUILD_ARCH in amd64 arm32v7 arm64v8;
|
||||
do
|
||||
echo " - commands:"
|
||||
echo " - \"authelia-scripts docker push-image --arch=${BUILD_ARCH}\""
|
||||
echo " label: \":docker: Deploy Image [${BUILD_ARCH}]\""
|
||||
echo " agents:"
|
||||
echo " "upload: fast""
|
||||
echo " env:"
|
||||
echo " "ARCH: ${BUILD_ARCH}""
|
||||
done
|
17
.buildkite/steps/e2etests.sh
Executable file
17
.buildkite/steps/e2etests.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
for SUITE_NAME in $(authelia-scripts suites list);
|
||||
do
|
||||
echo " - label: \":selenium: ${SUITE_NAME} Suite\""
|
||||
echo " commands:"
|
||||
echo " - \"authelia-scripts --log-level debug suites test ${SUITE_NAME} --headless\""
|
||||
if [[ "${SUITE_NAME}" != "Kubernetes" ]];
|
||||
then
|
||||
echo " agents:"
|
||||
echo " "suite: all""
|
||||
else
|
||||
echo " agents:"
|
||||
echo " "suite: kubernetes""
|
||||
fi
|
||||
done
|
11
.buildkite/steps/ghartifacts.sh
Executable file
11
.buildkite/steps/ghartifacts.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
artifacts=()
|
||||
|
||||
for FILES in authelia-linux-amd64.tar.gz authelia-linux-arm32v7.tar.gz authelia-linux-arm64v8.tar.gz authelia-linux-amd64.tar.gz.sha256 authelia-linux-arm32v7.tar.gz.sha256 authelia-linux-arm64v8.tar.gz.sha256;
|
||||
do
|
||||
artifacts+=(-a ${FILES})
|
||||
done
|
||||
|
||||
hub release create ${artifacts[@]} -m $BUILDKITE_TAG $BUILDKITE_TAG
|
13
.travis.yml
13
.travis.yml
|
@ -7,8 +7,6 @@ go:
|
|||
|
||||
services:
|
||||
- docker
|
||||
- ntp
|
||||
- xvfb
|
||||
|
||||
addons:
|
||||
chrome: stable
|
||||
|
@ -16,11 +14,10 @@ addons:
|
|||
sources:
|
||||
- google-chrome
|
||||
packages:
|
||||
- libgif-dev
|
||||
- google-chrome-stable
|
||||
|
||||
install:
|
||||
- export PATH=./cmd/authelia-scripts/:/tmp:$PATH
|
||||
- export PATH=$PATH:./cmd/authelia-scripts/:/tmp
|
||||
- source bootstrap.sh
|
||||
|
||||
jobs:
|
||||
|
@ -45,13 +42,13 @@ jobs:
|
|||
- wget -N https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_linux64.zip -P ~/
|
||||
- unzip ~/chromedriver_linux64.zip -d ~/
|
||||
- rm ~/chromedriver_linux64.zip
|
||||
- sudo mv -f ~/chromedriver /usr/local/bin/chromedriver
|
||||
- sudo chmod +x /usr/local/bin/chromedriver
|
||||
|
||||
- sudo mv -f ~/chromedriver /usr/bin/chromedriver
|
||||
- sudo chmod +x /usr/bin/chromedriver
|
||||
- sudo ln -s /usr/bin/google-chrome-stable /usr/bin/chromium-browser
|
||||
- go mod download
|
||||
script:
|
||||
# Run the suite
|
||||
- CI=true authelia-scripts --log-level debug suites test $SUITE_NAME --headless
|
||||
- authelia-scripts --log-level debug suites test $SUITE_NAME --headless
|
||||
# TODO(c.michaud): check if all suites are listed based on `authelia-scripts suites list` command.
|
||||
- <<: *e2e-test
|
||||
env:
|
||||
|
|
|
@ -42,7 +42,7 @@ WORKDIR /node/src/app
|
|||
COPY web .
|
||||
|
||||
# Install the dependencies and build
|
||||
RUN npm ci && npm run build
|
||||
RUN yarn install && yarn build
|
||||
|
||||
# ===================================
|
||||
# ===== Authelia official image =====
|
||||
|
|
18
Dockerfile.CI
Normal file
18
Dockerfile.CI
Normal file
|
@ -0,0 +1,18 @@
|
|||
# ===================================
|
||||
# ===== Authelia CI image =====
|
||||
# ===================================
|
||||
FROM alpine:3.10.3
|
||||
|
||||
RUN apk --no-cache add ca-certificates tzdata
|
||||
|
||||
WORKDIR /usr/app
|
||||
|
||||
COPY /dist/authelia authelia
|
||||
COPY /dist/public_html public_html
|
||||
|
||||
EXPOSE 9091
|
||||
|
||||
VOLUME /etc/authelia
|
||||
VOLUME /var/lib/authelia
|
||||
|
||||
CMD ["./authelia", "--config", "/etc/authelia/configuration.yml"]
|
|
@ -43,7 +43,7 @@ WORKDIR /node/src/app
|
|||
COPY web .
|
||||
|
||||
# Install the dependencies and build
|
||||
RUN npm ci && npm run build
|
||||
RUN yarn install && yarn build
|
||||
|
||||
# ===================================
|
||||
# ===== Authelia official image =====
|
||||
|
|
|
@ -43,7 +43,7 @@ WORKDIR /node/src/app
|
|||
COPY web .
|
||||
|
||||
# Install the dependencies and build
|
||||
RUN npm ci && npm run build
|
||||
RUN yarn install && yarn build
|
||||
|
||||
# ===================================
|
||||
# ===== Authelia official image =====
|
||||
|
|
21
bootstrap.sh
21
bootstrap.sh
|
@ -1,16 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
export PATH=./cmd/authelia-scripts/:/tmp:$PATH:./node_modules/.bin
|
||||
export PATH=$PATH:./cmd/authelia-scripts/:./node_modules/.bin:/tmp
|
||||
|
||||
if [ -z "$OLD_PS1" ]; then
|
||||
OLD_PS1="$PS1"
|
||||
export PS1="(authelia) $PS1"
|
||||
fi
|
||||
|
||||
if [ $(id -u) = 0 ]; then
|
||||
echo "Cannot run as root, defaulting to UID 1000"
|
||||
export USER_ID=1000
|
||||
else
|
||||
export USER_ID=$(id -u)
|
||||
export GROUP_ID=$(id -g)
|
||||
export CI=false
|
||||
fi
|
||||
|
||||
if [ $(id -g) = 0 ]; then
|
||||
echo "Cannot run as root, defaulting to GID 1000"
|
||||
export GROUP_ID=1000
|
||||
else
|
||||
export GROUP_ID=$(id -g)
|
||||
fi
|
||||
|
||||
if [ "$CI" == "true" ]; then
|
||||
true
|
||||
else
|
||||
export CI=false
|
||||
fi
|
||||
|
||||
echo "[BOOTSTRAP] Checking if Go is installed..."
|
||||
if [ ! -x "$(command -v go)" ];
|
||||
|
|
|
@ -68,7 +68,7 @@ func checkCommandExist(cmd string) {
|
|||
}
|
||||
|
||||
func installClientNpmPackages() {
|
||||
command := utils.CommandWithStdout("npm", "ci")
|
||||
command := utils.CommandWithStdout("yarn", "install")
|
||||
command.Dir = "client"
|
||||
err := command.Run()
|
||||
|
||||
|
@ -145,7 +145,7 @@ func prepareHostsFile() {
|
|||
|
||||
if modified {
|
||||
bootstrapPrintln("/etc/hosts needs to be updated")
|
||||
shell("/usr/bin/sudo mv /tmp/authelia/hosts /etc/hosts")
|
||||
shell("cat /tmp/authelia/hosts | sudo tee -a /etc/hosts > /dev/null")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ func buildAutheliaBinary() {
|
|||
|
||||
func buildFrontend() {
|
||||
// Install npm dependencies
|
||||
cmd := utils.CommandWithStdout("npm", "ci")
|
||||
cmd := utils.CommandWithStdout("yarn", "install")
|
||||
cmd.Dir = "web"
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
|
@ -31,7 +31,7 @@ func buildFrontend() {
|
|||
}
|
||||
|
||||
// Then build the frontend
|
||||
cmd = utils.CommandWithStdout("npm", "run", "build")
|
||||
cmd = utils.CommandWithStdout("yarn", "build")
|
||||
cmd.Dir = "web"
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
|
|
|
@ -14,14 +14,18 @@ import (
|
|||
|
||||
var arch string
|
||||
|
||||
var supportedArch = []string{"amd64", "arm32v7", "arm64v8"}
|
||||
var supportedArch = []string{"amd64", "arm32v7", "arm64v8", "CI"}
|
||||
var defaultArch = "amd64"
|
||||
var travisBranch = os.Getenv("TRAVIS_BRANCH")
|
||||
var travisPullRequest = os.Getenv("TRAVIS_PULL_REQUEST")
|
||||
var travisTag = os.Getenv("TRAVIS_TAG")
|
||||
var buildkite = os.Getenv("BUILDKITE")
|
||||
var buildkiteQEMU = os.Getenv("BUILDKITE_AGENT_META_DATA_QEMU")
|
||||
//TODO(nightah): Uncomment when turning off Travis
|
||||
//var ciBranch = os.Getenv("BUILDKITE_BRANCH")
|
||||
//var ciPullRequest = os.Getenv("BUILDKITE_PULL_REQUEST")
|
||||
//var ciTag = os.Getenv("BUILDKITE_TAG")
|
||||
var dockerTags = regexp.MustCompile(`v(?P<Patch>(?P<Minor>(?P<Major>\d+)\.\d+)\.\d+.*)`)
|
||||
var ignoredSuffixes = regexp.MustCompile("alpha|beta")
|
||||
var tags = dockerTags.FindStringSubmatch(travisTag)
|
||||
//var tags = dockerTags.FindStringSubmatch(ciTag)
|
||||
//TODO(nightah): Uncomment when turning off Travis
|
||||
|
||||
func init() {
|
||||
DockerBuildCmd.PersistentFlags().StringVar(&arch, "arch", defaultArch, "target architecture among: "+strings.Join(supportedArch, ", "))
|
||||
|
@ -44,38 +48,49 @@ func dockerBuildOfficialImage(arch string) error {
|
|||
// Set version of QEMU
|
||||
qemuversion := "v4.1.1-1"
|
||||
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
ciTag := ""
|
||||
if os.Getenv("TRAVIS_TAG") != "" {
|
||||
ciTag = os.Getenv("TRAVIS_TAG")
|
||||
} else {
|
||||
ciTag = os.Getenv("BUILDKITE_TAG")
|
||||
}
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
|
||||
// If not the default value
|
||||
if arch != defaultArch {
|
||||
dockerfile = fmt.Sprintf("%s.%s", dockerfile, arch)
|
||||
}
|
||||
|
||||
if arch == "arm32v7" {
|
||||
if buildkiteQEMU != "true" {
|
||||
err := utils.CommandWithStdout("docker", "run", "--rm", "--privileged", "multiarch/qemu-user-static", "--reset", "-p", "yes").Run()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
err = utils.CommandWithStdout("bash", "-c", "wget https://github.com/multiarch/qemu-user-static/releases/download/"+qemuversion+"/qemu-arm-static -O ./qemu-arm-static && chmod +x ./qemu-arm-static").Run()
|
||||
err := utils.CommandWithStdout("bash", "-c", "wget https://github.com/multiarch/qemu-user-static/releases/download/"+qemuversion+"/qemu-arm-static -O ./qemu-arm-static && chmod +x ./qemu-arm-static").Run()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else if arch == "arm64v8" {
|
||||
if buildkiteQEMU != "true" {
|
||||
err := utils.CommandWithStdout("docker", "run", "--rm", "--privileged", "multiarch/qemu-user-static", "--reset", "-p", "yes").Run()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
err = utils.CommandWithStdout("bash", "-c", "wget https://github.com/multiarch/qemu-user-static/releases/download/"+qemuversion+"/qemu-aarch64-static -O ./qemu-aarch64-static && chmod +x ./qemu-aarch64-static").Run()
|
||||
err := utils.CommandWithStdout("bash", "-c", "wget https://github.com/multiarch/qemu-user-static/releases/download/"+qemuversion+"/qemu-aarch64-static -O ./qemu-aarch64-static && chmod +x ./qemu-aarch64-static").Run()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
gitTag := travisTag
|
||||
gitTag := ciTag
|
||||
if gitTag == "" {
|
||||
// If commit is not tagged, mark the build has having unknown tag.
|
||||
gitTag = "unknown"
|
||||
|
@ -140,6 +155,10 @@ func login(docker *Docker) {
|
|||
username := os.Getenv("DOCKER_USERNAME")
|
||||
password := os.Getenv("DOCKER_PASSWORD")
|
||||
|
||||
if buildkite == "true" {
|
||||
return
|
||||
}
|
||||
|
||||
if username == "" {
|
||||
log.Fatal(errors.New("DOCKER_USERNAME is empty"))
|
||||
}
|
||||
|
@ -200,16 +219,38 @@ func deployManifest(docker *Docker, tag string, amd64tag string, arm32v7tag stri
|
|||
func publishDockerImage(arch string) {
|
||||
docker := &Docker{}
|
||||
|
||||
if travisBranch == "master" && travisPullRequest == "false" {
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
ciBranch := ""
|
||||
if os.Getenv("TRAVIS_BRANCH") != "" {
|
||||
ciBranch = os.Getenv("TRAVIS_BRANCH")
|
||||
} else {
|
||||
ciBranch = os.Getenv("BUILDKITE_BRANCH")
|
||||
}
|
||||
ciPullRequest := ""
|
||||
if os.Getenv("TRAVIS_PULL_REQUEST") != "" {
|
||||
ciPullRequest = os.Getenv("TRAVIS_PULL_REQUEST")
|
||||
} else {
|
||||
ciPullRequest = os.Getenv("BUILDKITE_PULL_REQUEST")
|
||||
}
|
||||
ciTag := ""
|
||||
if os.Getenv("TRAVIS_TAG") != "" {
|
||||
ciTag = os.Getenv("TRAVIS_TAG")
|
||||
} else {
|
||||
ciTag = os.Getenv("BUILDKITE_TAG")
|
||||
}
|
||||
tags := dockerTags.FindStringSubmatch(ciTag)
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
|
||||
if ciBranch == "master" && ciPullRequest == "false" {
|
||||
login(docker)
|
||||
deploy(docker, "master-"+arch)
|
||||
} else if travisTag != "" {
|
||||
} else if ciTag != "" {
|
||||
if len(tags) == 4 {
|
||||
fmt.Printf("Detected tags: '%s' | '%s' | '%s'", tags[1], tags[2], tags[3])
|
||||
log.Infof("Detected tags: '%s' | '%s' | '%s'", tags[1], tags[2], tags[3])
|
||||
|
||||
login(docker)
|
||||
deploy(docker, tags[1]+"-"+arch)
|
||||
if !ignoredSuffixes.MatchString(travisTag) {
|
||||
if !ignoredSuffixes.MatchString(ciTag) {
|
||||
deploy(docker, tags[2]+"-"+arch)
|
||||
deploy(docker, tags[3]+"-"+arch)
|
||||
deploy(docker, "latest-"+arch)
|
||||
|
@ -225,17 +266,39 @@ func publishDockerImage(arch string) {
|
|||
func publishDockerManifest() {
|
||||
docker := &Docker{}
|
||||
|
||||
if travisBranch == "master" && travisPullRequest == "false" {
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
ciBranch := ""
|
||||
if os.Getenv("TRAVIS_BRANCH") != "" {
|
||||
ciBranch = os.Getenv("TRAVIS_BRANCH")
|
||||
} else {
|
||||
ciBranch = os.Getenv("BUILDKITE_BRANCH")
|
||||
}
|
||||
ciPullRequest := ""
|
||||
if os.Getenv("TRAVIS_PULL_REQUEST") != "" {
|
||||
ciPullRequest = os.Getenv("TRAVIS_PULL_REQUEST")
|
||||
} else {
|
||||
ciPullRequest = os.Getenv("BUILDKITE_PULL_REQUEST")
|
||||
}
|
||||
ciTag := ""
|
||||
if os.Getenv("TRAVIS_TAG") != "" {
|
||||
ciTag = os.Getenv("TRAVIS_TAG")
|
||||
} else {
|
||||
ciTag = os.Getenv("BUILDKITE_TAG")
|
||||
}
|
||||
tags := dockerTags.FindStringSubmatch(ciTag)
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
|
||||
if ciBranch == "master" && ciPullRequest == "false" {
|
||||
login(docker)
|
||||
deployManifest(docker, "master", "master-amd64", "master-arm32v7", "master-arm64v8")
|
||||
} else if travisTag != "" {
|
||||
} else if ciTag != "" {
|
||||
if len(tags) == 4 {
|
||||
fmt.Printf("Detected tags: '%s' | '%s' | '%s'", tags[1], tags[2], tags[3])
|
||||
log.Infof("Detected tags: '%s' | '%s' | '%s'", tags[1], tags[2], tags[3])
|
||||
|
||||
login(docker)
|
||||
deployManifest(docker, tags[1], tags[1]+"-amd64", tags[1]+"-arm32v7", tags[1]+"-arm64v8")
|
||||
|
||||
if !ignoredSuffixes.MatchString(travisTag) {
|
||||
if !ignoredSuffixes.MatchString(ciTag) {
|
||||
deployManifest(docker, tags[2], tags[2]+"-amd64", tags[2]+"-arm32v7", tags[2]+"-arm64v8")
|
||||
deployManifest(docker, tags[3], tags[3]+"-amd64", tags[3]+"-arm32v7", tags[3]+"-arm64v8")
|
||||
deployManifest(docker, "latest", "latest-amd64", "latest-arm32v7", "latest-arm64v8")
|
||||
|
@ -244,6 +307,6 @@ func publishDockerManifest() {
|
|||
log.Fatal("Docker manifest will not be published, the specified tag does not conform to the standard")
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Docker manifest will not be published")
|
||||
log.Info("Docker manifest will not be published")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ func RunUnitTest(cobraCmd *cobra.Command, args []string) {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
cmd := utils.Shell("npm run test")
|
||||
cmd := utils.Shell("yarn test")
|
||||
cmd.Dir = "web"
|
||||
cmd.Env = append(os.Environ(), "CI=true")
|
||||
if err := cmd.Run(); err != nil {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
FROM golang:1.13-alpine
|
||||
|
||||
RUN apk --no-cache add gcc musl-dev
|
||||
#TODO(nightah): Remove when turning off Travis
|
||||
ARG TRAVIS
|
||||
RUN if [ "$TRAVIS" == "true" ]; then apk --no-cache add gcc musl-dev; fi
|
||||
#TODO(nightah): Remove when turning off Travis
|
||||
|
||||
ARG USER_ID
|
||||
ARG GROUP_ID
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
version: "3"
|
||||
services:
|
||||
authelia-backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
environment:
|
||||
- ENVIRONMENT=dev
|
||||
restart: always
|
||||
networks:
|
||||
authelianet:
|
||||
ipv4_address: 192.168.240.50
|
|
@ -3,7 +3,7 @@ services:
|
|||
authelia-backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
dockerfile: Dockerfile.CI
|
||||
environment:
|
||||
- ENVIRONMENT=dev
|
||||
restart: always
|
||||
|
|
|
@ -7,7 +7,8 @@ services:
|
|||
args:
|
||||
USER_ID: ${USER_ID}
|
||||
GROUP_ID: ${GROUP_ID}
|
||||
command: /resources/entrypoint.sh
|
||||
TRAVIS: ${TRAVIS}
|
||||
command: /resources/entrypoint-backend.sh
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- "./example/compose/authelia/resources/:/resources"
|
||||
|
@ -16,6 +17,7 @@ services:
|
|||
environment:
|
||||
- ENVIRONMENT=dev
|
||||
- CI=${CI}
|
||||
- TRAVIS=${TRAVIS}
|
||||
networks:
|
||||
authelianet:
|
||||
ipv4_address: 192.168.240.50
|
|
@ -3,6 +3,6 @@ services:
|
|||
authelia-frontend:
|
||||
image: nginx:alpine
|
||||
volumes:
|
||||
- ./example/compose/authelia/resources/nginx.conf:/etc/nginx/nginx.conf
|
||||
- "./example/compose/authelia/resources/nginx.conf:/etc/nginx/nginx.conf"
|
||||
networks:
|
||||
- authelianet
|
|
@ -7,9 +7,13 @@ services:
|
|||
args:
|
||||
USER_ID: ${USER_ID}
|
||||
GROUP_ID: ${GROUP_ID}
|
||||
command: sh -c 'npm ci && npm run start'
|
||||
command: /resources/entrypoint-frontend.sh
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- "./example/compose/authelia/resources/:/resources"
|
||||
- "./web:/app"
|
||||
environment:
|
||||
- CI=${CI}
|
||||
- TRAVIS=${TRAVIS}
|
||||
networks:
|
||||
- authelianet
|
18
example/compose/authelia/resources/entrypoint-backend.sh
Executable file
18
example/compose/authelia/resources/entrypoint-backend.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
if [ "$CI" == "true" ];
|
||||
then
|
||||
echo "Use CI version of Authelia"
|
||||
/resources/run-backend.sh
|
||||
else
|
||||
echo "Use hot reloaded version of Authelia backend"
|
||||
go get github.com/cespare/reflex
|
||||
|
||||
# Sleep 10 seconds to wait the end of npm install updating web directory
|
||||
# and making reflex reload multiple times.
|
||||
sleep 10
|
||||
|
||||
reflex -c /resources/reflex.conf
|
||||
fi
|
11
example/compose/authelia/resources/entrypoint-frontend.sh
Executable file
11
example/compose/authelia/resources/entrypoint-frontend.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
if [ "$CI" == "true" ] && [ "$TRAVIS" != "true" ];
|
||||
then
|
||||
echo "Use CI version of Authelia frontend"
|
||||
/resources/run-frontend.sh
|
||||
else
|
||||
yarn install && yarn start
|
||||
fi
|
|
@ -1,18 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
if [ "$CI" == "true" ];
|
||||
then
|
||||
echo "Use static version of Authelia"
|
||||
/resources/run.sh
|
||||
else
|
||||
echo "Use hot reloaded version of Authelia"
|
||||
go get github.com/cespare/reflex
|
||||
|
||||
# Sleep 10 seconds to wait the end of npm install updating web directory
|
||||
# and making reflex reload multiple times.
|
||||
sleep 10
|
||||
|
||||
reflex -c /resources/reflex.conf
|
||||
fi
|
|
@ -1 +1 @@
|
|||
-r '(\.go$|go\.mod|\.sh|\.yml)' -s /resources/run.sh
|
||||
-r '(\.go$|go\.mod|\.sh|\.yml)' -s /resources/run-backend.sh
|
15
example/compose/authelia/resources/run-backend.sh
Executable file
15
example/compose/authelia/resources/run-backend.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
#TODO(nightah): Remove when turning off Travis
|
||||
if [ "$CI" == "true" ] && [ "$TRAVIS" == "true" ];
|
||||
then
|
||||
go build -o /app/dist/authelia cmd/authelia/*.go
|
||||
fi
|
||||
#TODO(nightah): Remove when turning off Travis
|
||||
|
||||
while /app/dist/authelia --config /etc/authelia/configuration.yml; [ $? -ne 0 ];
|
||||
do
|
||||
echo "Waiting on services for Authelia"
|
||||
done
|
5
example/compose/authelia/resources/run-frontend.sh
Executable file
5
example/compose/authelia/resources/run-frontend.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
yarn start
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# Build the binary
|
||||
go build -o /tmp/authelia/authelia-tmp cmd/authelia/*.go
|
||||
|
||||
while true;
|
||||
do
|
||||
/tmp/authelia/authelia-tmp --config /etc/authelia/configuration.yml
|
||||
sleep 10
|
||||
done
|
|
@ -3,7 +3,7 @@ FROM node:12-alpine
|
|||
WORKDIR /usr/app/src
|
||||
|
||||
ADD package.json package.json
|
||||
RUN npm install --production --quiet
|
||||
RUN yarn install --production --silent
|
||||
|
||||
ADD duo_api.js duo_api.js
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ func (p *LDAPUserProvider) getUserAttribute(conn LDAPConnection, username string
|
|||
defer client.Close()
|
||||
|
||||
userFilter := strings.Replace(p.configuration.UsersFilter, "{0}", username, -1)
|
||||
var baseDN string = p.configuration.BaseDN
|
||||
baseDN := p.configuration.BaseDN
|
||||
if p.configuration.AdditionalUsersDN != "" {
|
||||
baseDN = p.configuration.AdditionalUsersDN + "," + baseDN
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ func (p *LDAPUserProvider) GetDetails(username string) (*UserDetails, error) {
|
|||
return nil, fmt.Errorf("Unable to create group filter for user %s. Cause: %s", username, err)
|
||||
}
|
||||
|
||||
var groupBaseDN string = p.configuration.BaseDN
|
||||
groupBaseDN := p.configuration.BaseDN
|
||||
if p.configuration.AdditionalGroupsDN != "" {
|
||||
groupBaseDN = p.configuration.AdditionalGroupsDN + "," + groupBaseDN
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ func init() {
|
|||
return err
|
||||
}
|
||||
|
||||
return waitUntilAutheliaBackendIsReady(dockerEnvironment)
|
||||
return waitUntilAutheliaIsReady(dockerEnvironment)
|
||||
}
|
||||
|
||||
onSetupTimeout := func() error {
|
||||
|
|
|
@ -2,14 +2,27 @@ package suites
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
travis := os.Getenv("TRAVIS")
|
||||
backend := ""
|
||||
if travis == "true" {
|
||||
backend = "example/compose/authelia/docker-compose.backend-dist-travis.yml"
|
||||
} else {
|
||||
backend = "example/compose/authelia/docker-compose.backend-dist.yml"
|
||||
}
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
|
||||
dockerEnvironment := NewDockerEnvironment([]string{
|
||||
"docker-compose.yml",
|
||||
"internal/suites/Docker/docker-compose.yml",
|
||||
"example/compose/authelia/docker-compose.backend-dist.yml",
|
||||
//TODO(nightah): Change to "example/compose/authelia/docker-compose.backend-dist.yml" when removing Travis
|
||||
backend,
|
||||
"example/compose/authelia/docker-compose.frontend-dist.yml",
|
||||
"example/compose/nginx/backend/docker-compose.yml",
|
||||
"example/compose/nginx/portal/docker-compose.yml",
|
||||
|
|
|
@ -23,7 +23,7 @@ func init() {
|
|||
return err
|
||||
}
|
||||
|
||||
return waitUntilAutheliaBackendIsReady(dockerEnvironment)
|
||||
return waitUntilAutheliaIsReady(dockerEnvironment)
|
||||
}
|
||||
|
||||
onSetupTimeout := func() error {
|
||||
|
|
|
@ -28,7 +28,7 @@ func init() {
|
|||
return err
|
||||
}
|
||||
|
||||
return waitUntilAutheliaBackendIsReady(haDockerEnvironment)
|
||||
return waitUntilAutheliaIsReady(haDockerEnvironment)
|
||||
}
|
||||
|
||||
onSetupTimeout := func() error {
|
||||
|
|
|
@ -2,6 +2,8 @@ package suites
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/authelia/authelia/internal/utils"
|
||||
|
@ -42,9 +44,18 @@ func init() {
|
|||
}
|
||||
|
||||
log.Debug("Building authelia:dist image...")
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
travis := os.Getenv("TRAVIS")
|
||||
if travis == "true" {
|
||||
if err := utils.Shell("authelia-scripts docker build").Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := utils.Shell("authelia-scripts docker build --arch=CI").Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
//TODO(nightah): Remove when turning off Travis
|
||||
|
||||
log.Debug("Loading images into Kubernetes container...")
|
||||
if err = loadDockerImages(); err != nil {
|
||||
|
@ -91,7 +102,7 @@ func init() {
|
|||
|
||||
GlobalRegistry.Register(kubernetesSuiteName, Suite{
|
||||
SetUp: setup,
|
||||
SetUpTimeout: 10 * time.Minute,
|
||||
SetUpTimeout: 12 * time.Minute,
|
||||
TestTimeout: 2 * time.Minute,
|
||||
TearDown: teardown,
|
||||
TearDownTimeout: 2 * time.Minute,
|
||||
|
|
|
@ -27,7 +27,7 @@ func init() {
|
|||
return err
|
||||
}
|
||||
|
||||
return waitUntilAutheliaBackendIsReady(dockerEnvironment)
|
||||
return waitUntilAutheliaIsReady(dockerEnvironment)
|
||||
}
|
||||
|
||||
onSetupTimeout := func() error {
|
||||
|
|
|
@ -25,7 +25,7 @@ func init() {
|
|||
return err
|
||||
}
|
||||
|
||||
return waitUntilAutheliaBackendIsReady(dockerEnvironment)
|
||||
return waitUntilAutheliaIsReady(dockerEnvironment)
|
||||
}
|
||||
|
||||
onSetupTimeout := func() error {
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
return err
|
||||
}
|
||||
|
||||
return waitUntilAutheliaBackendIsReady(dockerEnvironment)
|
||||
return waitUntilAutheliaIsReady(dockerEnvironment)
|
||||
}
|
||||
|
||||
onSetupTimeout := func() error {
|
||||
|
|
|
@ -25,7 +25,7 @@ func init() {
|
|||
return err
|
||||
}
|
||||
|
||||
return waitUntilAutheliaBackendIsReady(dockerEnvironment)
|
||||
return waitUntilAutheliaIsReady(dockerEnvironment)
|
||||
}
|
||||
|
||||
onSetupTimeout := func() error {
|
||||
|
|
|
@ -23,7 +23,7 @@ func init() {
|
|||
return err
|
||||
}
|
||||
|
||||
return waitUntilAutheliaBackendIsReady(dockerEnvironment)
|
||||
return waitUntilAutheliaIsReady(dockerEnvironment)
|
||||
}
|
||||
|
||||
onSetupTimeout := func() error {
|
||||
|
|
|
@ -25,7 +25,7 @@ func init() {
|
|||
return err
|
||||
}
|
||||
|
||||
return waitUntilAutheliaBackendIsReady(dockerEnvironment)
|
||||
return waitUntilAutheliaIsReady(dockerEnvironment)
|
||||
}
|
||||
|
||||
onSetupTimeout := func() error {
|
||||
|
|
|
@ -25,7 +25,7 @@ func init() {
|
|||
return err
|
||||
}
|
||||
|
||||
return waitUntilAutheliaBackendIsReady(dockerEnvironment)
|
||||
return waitUntilAutheliaIsReady(dockerEnvironment)
|
||||
}
|
||||
|
||||
onSetupTimeout := func() error {
|
||||
|
@ -52,6 +52,7 @@ func init() {
|
|||
SetUp: setup,
|
||||
SetUpTimeout: 5 * time.Minute,
|
||||
OnSetupTimeout: onSetupTimeout,
|
||||
TestTimeout: 2 * time.Minute,
|
||||
TearDown: teardown,
|
||||
TearDownTimeout: 2 * time.Minute,
|
||||
})
|
||||
|
|
|
@ -21,18 +21,19 @@ type WebDriverSession struct {
|
|||
|
||||
// StartWebDriverWithProxy create a selenium session
|
||||
func StartWebDriverWithProxy(proxy string, port int) (*WebDriverSession, error) {
|
||||
service, err := selenium.NewChromeDriverService("/usr/local/bin/chromedriver", port)
|
||||
service, err := selenium.NewChromeDriverService("/usr/bin/chromedriver", port)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
chromeCaps := chrome.Capabilities{
|
||||
Path: "/usr/bin/google-chrome-stable",
|
||||
Path: "/usr/bin/chromium-browser",
|
||||
}
|
||||
|
||||
if os.Getenv("HEADLESS") != "" {
|
||||
chromeCaps.Args = append(chromeCaps.Args, "--headless")
|
||||
chromeCaps.Args = append(chromeCaps.Args, "--no-sandbox")
|
||||
}
|
||||
|
||||
if proxy != "" {
|
||||
|
|
14341
web/package-lock.json
generated
14341
web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11312
web/yarn.lock
Normal file
11312
web/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user