Utilise Buildkite for Authelia CI/CD (#507)

Publish steps are currently disabled.
pull/523/head
Amir Zarrinkafsh 2019-12-27 22:07:53 +11:00 committed by GitHub
parent 511b0b3c62
commit 2fb20882d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 11757 additions and 14447 deletions

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View File

@ -7,8 +7,6 @@ go:
services: services:
- docker - docker
- ntp
- xvfb
addons: addons:
chrome: stable chrome: stable
@ -16,11 +14,10 @@ addons:
sources: sources:
- google-chrome - google-chrome
packages: packages:
- libgif-dev
- google-chrome-stable - google-chrome-stable
install: install:
- export PATH=./cmd/authelia-scripts/:/tmp:$PATH - export PATH=$PATH:./cmd/authelia-scripts/:/tmp
- source bootstrap.sh - source bootstrap.sh
jobs: jobs:
@ -45,13 +42,13 @@ jobs:
- wget -N https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_linux64.zip -P ~/ - wget -N https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_linux64.zip -P ~/
- unzip ~/chromedriver_linux64.zip -d ~/ - unzip ~/chromedriver_linux64.zip -d ~/
- rm ~/chromedriver_linux64.zip - rm ~/chromedriver_linux64.zip
- sudo mv -f ~/chromedriver /usr/local/bin/chromedriver - sudo mv -f ~/chromedriver /usr/bin/chromedriver
- sudo chmod +x /usr/local/bin/chromedriver - sudo chmod +x /usr/bin/chromedriver
- sudo ln -s /usr/bin/google-chrome-stable /usr/bin/chromium-browser
- go mod download - go mod download
script: script:
# Run the suite # 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. # TODO(c.michaud): check if all suites are listed based on `authelia-scripts suites list` command.
- <<: *e2e-test - <<: *e2e-test
env: env:

View File

@ -42,7 +42,7 @@ WORKDIR /node/src/app
COPY web . COPY web .
# Install the dependencies and build # Install the dependencies and build
RUN npm ci && npm run build RUN yarn install && yarn build
# =================================== # ===================================
# ===== Authelia official image ===== # ===== Authelia official image =====

18
Dockerfile.CI 100644
View 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"]

View File

@ -43,7 +43,7 @@ WORKDIR /node/src/app
COPY web . COPY web .
# Install the dependencies and build # Install the dependencies and build
RUN npm ci && npm run build RUN yarn install && yarn build
# =================================== # ===================================
# ===== Authelia official image ===== # ===== Authelia official image =====

View File

@ -43,7 +43,7 @@ WORKDIR /node/src/app
COPY web . COPY web .
# Install the dependencies and build # Install the dependencies and build
RUN npm ci && npm run build RUN yarn install && yarn build
# =================================== # ===================================
# ===== Authelia official image ===== # ===== Authelia official image =====

View File

@ -1,16 +1,31 @@
#!/bin/bash #!/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 if [ -z "$OLD_PS1" ]; then
OLD_PS1="$PS1" OLD_PS1="$PS1"
export PS1="(authelia) $PS1" export PS1="(authelia) $PS1"
fi fi
export USER_ID=$(id -u) if [ $(id -u) = 0 ]; then
export GROUP_ID=$(id -g) echo "Cannot run as root, defaulting to UID 1000"
export CI=false export USER_ID=1000
else
export USER_ID=$(id -u)
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..." echo "[BOOTSTRAP] Checking if Go is installed..."
if [ ! -x "$(command -v go)" ]; if [ ! -x "$(command -v go)" ];

View File

@ -68,7 +68,7 @@ func checkCommandExist(cmd string) {
} }
func installClientNpmPackages() { func installClientNpmPackages() {
command := utils.CommandWithStdout("npm", "ci") command := utils.CommandWithStdout("yarn", "install")
command.Dir = "client" command.Dir = "client"
err := command.Run() err := command.Run()
@ -145,7 +145,7 @@ func prepareHostsFile() {
if modified { if modified {
bootstrapPrintln("/etc/hosts needs to be updated") 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")
} }
} }

View File

@ -23,7 +23,7 @@ func buildAutheliaBinary() {
func buildFrontend() { func buildFrontend() {
// Install npm dependencies // Install npm dependencies
cmd := utils.CommandWithStdout("npm", "ci") cmd := utils.CommandWithStdout("yarn", "install")
cmd.Dir = "web" cmd.Dir = "web"
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
@ -31,7 +31,7 @@ func buildFrontend() {
} }
// Then build the frontend // Then build the frontend
cmd = utils.CommandWithStdout("npm", "run", "build") cmd = utils.CommandWithStdout("yarn", "build")
cmd.Dir = "web" cmd.Dir = "web"
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {

View File

@ -14,14 +14,18 @@ import (
var arch string var arch string
var supportedArch = []string{"amd64", "arm32v7", "arm64v8"} var supportedArch = []string{"amd64", "arm32v7", "arm64v8", "CI"}
var defaultArch = "amd64" var defaultArch = "amd64"
var travisBranch = os.Getenv("TRAVIS_BRANCH") var buildkite = os.Getenv("BUILDKITE")
var travisPullRequest = os.Getenv("TRAVIS_PULL_REQUEST") var buildkiteQEMU = os.Getenv("BUILDKITE_AGENT_META_DATA_QEMU")
var travisTag = os.Getenv("TRAVIS_TAG") //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 dockerTags = regexp.MustCompile(`v(?P<Patch>(?P<Minor>(?P<Major>\d+)\.\d+)\.\d+.*)`)
var ignoredSuffixes = regexp.MustCompile("alpha|beta") 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() { func init() {
DockerBuildCmd.PersistentFlags().StringVar(&arch, "arch", defaultArch, "target architecture among: "+strings.Join(supportedArch, ", ")) 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 // Set version of QEMU
qemuversion := "v4.1.1-1" 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 not the default value
if arch != defaultArch { if arch != defaultArch {
dockerfile = fmt.Sprintf("%s.%s", dockerfile, arch) dockerfile = fmt.Sprintf("%s.%s", dockerfile, arch)
} }
if arch == "arm32v7" { if arch == "arm32v7" {
err := utils.CommandWithStdout("docker", "run", "--rm", "--privileged", "multiarch/qemu-user-static", "--reset", "-p", "yes").Run() if buildkiteQEMU != "true" {
err := utils.CommandWithStdout("docker", "run", "--rm", "--privileged", "multiarch/qemu-user-static", "--reset", "-p", "yes").Run()
if err != nil { if err != nil {
panic(err) 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 { if err != nil {
panic(err) panic(err)
} }
} else if arch == "arm64v8" { } else if arch == "arm64v8" {
err := utils.CommandWithStdout("docker", "run", "--rm", "--privileged", "multiarch/qemu-user-static", "--reset", "-p", "yes").Run() if buildkiteQEMU != "true" {
err := utils.CommandWithStdout("docker", "run", "--rm", "--privileged", "multiarch/qemu-user-static", "--reset", "-p", "yes").Run()
if err != nil { if err != nil {
panic(err) 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 { if err != nil {
panic(err) panic(err)
} }
} }
gitTag := travisTag gitTag := ciTag
if gitTag == "" { if gitTag == "" {
// If commit is not tagged, mark the build has having unknown tag. // If commit is not tagged, mark the build has having unknown tag.
gitTag = "unknown" gitTag = "unknown"
@ -140,6 +155,10 @@ func login(docker *Docker) {
username := os.Getenv("DOCKER_USERNAME") username := os.Getenv("DOCKER_USERNAME")
password := os.Getenv("DOCKER_PASSWORD") password := os.Getenv("DOCKER_PASSWORD")
if buildkite == "true" {
return
}
if username == "" { if username == "" {
log.Fatal(errors.New("DOCKER_USERNAME is empty")) 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) { func publishDockerImage(arch string) {
docker := &Docker{} 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) login(docker)
deploy(docker, "master-"+arch) deploy(docker, "master-"+arch)
} else if travisTag != "" { } else if ciTag != "" {
if len(tags) == 4 { 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) login(docker)
deploy(docker, tags[1]+"-"+arch) deploy(docker, tags[1]+"-"+arch)
if !ignoredSuffixes.MatchString(travisTag) { if !ignoredSuffixes.MatchString(ciTag) {
deploy(docker, tags[2]+"-"+arch) deploy(docker, tags[2]+"-"+arch)
deploy(docker, tags[3]+"-"+arch) deploy(docker, tags[3]+"-"+arch)
deploy(docker, "latest-"+arch) deploy(docker, "latest-"+arch)
@ -225,17 +266,39 @@ func publishDockerImage(arch string) {
func publishDockerManifest() { func publishDockerManifest() {
docker := &Docker{} 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) login(docker)
deployManifest(docker, "master", "master-amd64", "master-arm32v7", "master-arm64v8") deployManifest(docker, "master", "master-amd64", "master-arm32v7", "master-arm64v8")
} else if travisTag != "" { } else if ciTag != "" {
if len(tags) == 4 { 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) login(docker)
deployManifest(docker, tags[1], tags[1]+"-amd64", tags[1]+"-arm32v7", tags[1]+"-arm64v8") 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[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, tags[3], tags[3]+"-amd64", tags[3]+"-arm32v7", tags[3]+"-arm64v8")
deployManifest(docker, "latest", "latest-amd64", "latest-arm32v7", "latest-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") log.Fatal("Docker manifest will not be published, the specified tag does not conform to the standard")
} }
} else { } else {
fmt.Println("Docker manifest will not be published") log.Info("Docker manifest will not be published")
} }
} }

View File

@ -14,7 +14,7 @@ func RunUnitTest(cobraCmd *cobra.Command, args []string) {
log.Fatal(err) log.Fatal(err)
} }
cmd := utils.Shell("npm run test") cmd := utils.Shell("yarn test")
cmd.Dir = "web" cmd.Dir = "web"
cmd.Env = append(os.Environ(), "CI=true") cmd.Env = append(os.Environ(), "CI=true")
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {

View File

@ -1,6 +1,9 @@
FROM golang:1.13-alpine 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 USER_ID
ARG GROUP_ID ARG GROUP_ID

View File

@ -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

View File

@ -3,7 +3,7 @@ services:
authelia-backend: authelia-backend:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile.CI
environment: environment:
- ENVIRONMENT=dev - ENVIRONMENT=dev
restart: always restart: always

View File

@ -7,7 +7,8 @@ services:
args: args:
USER_ID: ${USER_ID} USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_ID} GROUP_ID: ${GROUP_ID}
command: /resources/entrypoint.sh TRAVIS: ${TRAVIS}
command: /resources/entrypoint-backend.sh
working_dir: /app working_dir: /app
volumes: volumes:
- "./example/compose/authelia/resources/:/resources" - "./example/compose/authelia/resources/:/resources"
@ -16,6 +17,7 @@ services:
environment: environment:
- ENVIRONMENT=dev - ENVIRONMENT=dev
- CI=${CI} - CI=${CI}
- TRAVIS=${TRAVIS}
networks: networks:
authelianet: authelianet:
ipv4_address: 192.168.240.50 ipv4_address: 192.168.240.50

View File

@ -3,6 +3,6 @@ services:
authelia-frontend: authelia-frontend:
image: nginx:alpine image: nginx:alpine
volumes: volumes:
- ./example/compose/authelia/resources/nginx.conf:/etc/nginx/nginx.conf - "./example/compose/authelia/resources/nginx.conf:/etc/nginx/nginx.conf"
networks: networks:
- authelianet - authelianet

View File

@ -7,9 +7,13 @@ services:
args: args:
USER_ID: ${USER_ID} USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_ID} GROUP_ID: ${GROUP_ID}
command: sh -c 'npm ci && npm run start' command: /resources/entrypoint-frontend.sh
working_dir: /app working_dir: /app
volumes: volumes:
- "./example/compose/authelia/resources/:/resources"
- "./web:/app" - "./web:/app"
environment:
- CI=${CI}
- TRAVIS=${TRAVIS}
networks: networks:
- authelianet - authelianet

View 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

View 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

View File

@ -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

View File

@ -1 +1 @@
-r '(\.go$|go\.mod|\.sh|\.yml)' -s /resources/run.sh -r '(\.go$|go\.mod|\.sh|\.yml)' -s /resources/run-backend.sh

View 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

View File

@ -0,0 +1,5 @@
#!/bin/sh
set -e
yarn start

View File

@ -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

View File

@ -3,7 +3,7 @@ FROM node:12-alpine
WORKDIR /usr/app/src WORKDIR /usr/app/src
ADD package.json package.json ADD package.json package.json
RUN npm install --production --quiet RUN yarn install --production --silent
ADD duo_api.js duo_api.js ADD duo_api.js duo_api.js

View File

@ -97,7 +97,7 @@ func (p *LDAPUserProvider) getUserAttribute(conn LDAPConnection, username string
defer client.Close() defer client.Close()
userFilter := strings.Replace(p.configuration.UsersFilter, "{0}", username, -1) userFilter := strings.Replace(p.configuration.UsersFilter, "{0}", username, -1)
var baseDN string = p.configuration.BaseDN baseDN := p.configuration.BaseDN
if p.configuration.AdditionalUsersDN != "" { if p.configuration.AdditionalUsersDN != "" {
baseDN = p.configuration.AdditionalUsersDN + "," + baseDN 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) 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 != "" { if p.configuration.AdditionalGroupsDN != "" {
groupBaseDN = p.configuration.AdditionalGroupsDN + "," + groupBaseDN groupBaseDN = p.configuration.AdditionalGroupsDN + "," + groupBaseDN
} }

View File

@ -25,7 +25,7 @@ func init() {
return err return err
} }
return waitUntilAutheliaBackendIsReady(dockerEnvironment) return waitUntilAutheliaIsReady(dockerEnvironment)
} }
onSetupTimeout := func() error { onSetupTimeout := func() error {

View File

@ -2,14 +2,27 @@ package suites
import ( import (
"fmt" "fmt"
//TODO(nightah): Remove when turning off Travis
"os"
"time" "time"
) )
func init() { 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{ dockerEnvironment := NewDockerEnvironment([]string{
"docker-compose.yml", "docker-compose.yml",
"internal/suites/Docker/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/authelia/docker-compose.frontend-dist.yml",
"example/compose/nginx/backend/docker-compose.yml", "example/compose/nginx/backend/docker-compose.yml",
"example/compose/nginx/portal/docker-compose.yml", "example/compose/nginx/portal/docker-compose.yml",

View File

@ -23,7 +23,7 @@ func init() {
return err return err
} }
return waitUntilAutheliaBackendIsReady(dockerEnvironment) return waitUntilAutheliaIsReady(dockerEnvironment)
} }
onSetupTimeout := func() error { onSetupTimeout := func() error {

View File

@ -28,7 +28,7 @@ func init() {
return err return err
} }
return waitUntilAutheliaBackendIsReady(haDockerEnvironment) return waitUntilAutheliaIsReady(haDockerEnvironment)
} }
onSetupTimeout := func() error { onSetupTimeout := func() error {

View File

@ -2,6 +2,8 @@ package suites
import ( import (
"fmt" "fmt"
//TODO(nightah): Remove when turning off Travis
"os"
"time" "time"
"github.com/authelia/authelia/internal/utils" "github.com/authelia/authelia/internal/utils"
@ -42,9 +44,18 @@ func init() {
} }
log.Debug("Building authelia:dist image...") log.Debug("Building authelia:dist image...")
if err := utils.Shell("authelia-scripts docker build").Run(); err != nil { //TODO(nightah): Remove when turning off Travis
return err 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...") log.Debug("Loading images into Kubernetes container...")
if err = loadDockerImages(); err != nil { if err = loadDockerImages(); err != nil {
@ -91,7 +102,7 @@ func init() {
GlobalRegistry.Register(kubernetesSuiteName, Suite{ GlobalRegistry.Register(kubernetesSuiteName, Suite{
SetUp: setup, SetUp: setup,
SetUpTimeout: 10 * time.Minute, SetUpTimeout: 12 * time.Minute,
TestTimeout: 2 * time.Minute, TestTimeout: 2 * time.Minute,
TearDown: teardown, TearDown: teardown,
TearDownTimeout: 2 * time.Minute, TearDownTimeout: 2 * time.Minute,

View File

@ -27,7 +27,7 @@ func init() {
return err return err
} }
return waitUntilAutheliaBackendIsReady(dockerEnvironment) return waitUntilAutheliaIsReady(dockerEnvironment)
} }
onSetupTimeout := func() error { onSetupTimeout := func() error {

View File

@ -25,7 +25,7 @@ func init() {
return err return err
} }
return waitUntilAutheliaBackendIsReady(dockerEnvironment) return waitUntilAutheliaIsReady(dockerEnvironment)
} }
onSetupTimeout := func() error { onSetupTimeout := func() error {

View File

@ -26,7 +26,7 @@ func init() {
return err return err
} }
return waitUntilAutheliaBackendIsReady(dockerEnvironment) return waitUntilAutheliaIsReady(dockerEnvironment)
} }
onSetupTimeout := func() error { onSetupTimeout := func() error {

View File

@ -25,7 +25,7 @@ func init() {
return err return err
} }
return waitUntilAutheliaBackendIsReady(dockerEnvironment) return waitUntilAutheliaIsReady(dockerEnvironment)
} }
onSetupTimeout := func() error { onSetupTimeout := func() error {

View File

@ -23,7 +23,7 @@ func init() {
return err return err
} }
return waitUntilAutheliaBackendIsReady(dockerEnvironment) return waitUntilAutheliaIsReady(dockerEnvironment)
} }
onSetupTimeout := func() error { onSetupTimeout := func() error {

View File

@ -25,7 +25,7 @@ func init() {
return err return err
} }
return waitUntilAutheliaBackendIsReady(dockerEnvironment) return waitUntilAutheliaIsReady(dockerEnvironment)
} }
onSetupTimeout := func() error { onSetupTimeout := func() error {

View File

@ -25,7 +25,7 @@ func init() {
return err return err
} }
return waitUntilAutheliaBackendIsReady(dockerEnvironment) return waitUntilAutheliaIsReady(dockerEnvironment)
} }
onSetupTimeout := func() error { onSetupTimeout := func() error {
@ -52,6 +52,7 @@ func init() {
SetUp: setup, SetUp: setup,
SetUpTimeout: 5 * time.Minute, SetUpTimeout: 5 * time.Minute,
OnSetupTimeout: onSetupTimeout, OnSetupTimeout: onSetupTimeout,
TestTimeout: 2 * time.Minute,
TearDown: teardown, TearDown: teardown,
TearDownTimeout: 2 * time.Minute, TearDownTimeout: 2 * time.Minute,
}) })

View File

@ -21,18 +21,19 @@ type WebDriverSession struct {
// StartWebDriverWithProxy create a selenium session // StartWebDriverWithProxy create a selenium session
func StartWebDriverWithProxy(proxy string, port int) (*WebDriverSession, error) { 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 { if err != nil {
return nil, err return nil, err
} }
chromeCaps := chrome.Capabilities{ chromeCaps := chrome.Capabilities{
Path: "/usr/bin/google-chrome-stable", Path: "/usr/bin/chromium-browser",
} }
if os.Getenv("HEADLESS") != "" { if os.Getenv("HEADLESS") != "" {
chromeCaps.Args = append(chromeCaps.Args, "--headless") chromeCaps.Args = append(chromeCaps.Args, "--headless")
chromeCaps.Args = append(chromeCaps.Args, "--no-sandbox")
} }
if proxy != "" { if proxy != "" {

14341
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

11312
web/yarn.lock 100644

File diff suppressed because it is too large Load Diff