-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding docker image and release scripts (#123)
* Adding docker image and release scripts * Using circleci version 2 * now building dumb-init and gosu from source * trying to fix e2e tests * fixing working directory for circleci version 2 * start atlantis server and ngrok in the background * Adding terraform to path and removing old decryption method for circleci * adding terraform binary to the correct path * ATLANTIS_URL is now being exported * using circleci version 2 syntax to export variable * using circleci version 2 syntax to export variable * ngrok isnt working now * Updating CHANGELOG * Fixes after review and updated README.md
- Loading branch information
1 parent
ea9536a
commit 6b55b08
Showing
13 changed files
with
238 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
working_directory: /go/src/github.com/hootsuite/atlantis | ||
docker: | ||
- image: circleci/golang:1.8 | ||
environment: | ||
TERRAFORM_VERSION: 0.10.0 | ||
steps: | ||
- checkout | ||
- setup_remote_docker: | ||
reusable: true | ||
- run: make deps | ||
- run: make test | ||
- run: make build-service | ||
- run: | ||
name: Install e2e dependencies | ||
command: make end-to-end-deps | ||
- run: | ||
name: Starting atlantis server in the background | ||
command: cd "${CIRCLE_WORKING_DIRECTORY}/e2e" && ./atlantis server --gh-user="$GITHUB_USERNAME" --gh-token="$GITHUB_PASSWORD" --data-dir="/tmp" --log-level="debug" &> /tmp/atlantis-server.log | ||
background: true | ||
- run: sleep 2 | ||
- run: | ||
name: Starting ngrok | ||
command: cd "${CIRCLE_WORKING_DIRECTORY}/e2e" && ./ngrok http 4141 > /tmp/ngrok.log | ||
background: true | ||
- run: sleep 2 | ||
- run: echo 'export ATLANTIS_URL=$(curl -s 'http://localhost:4040/api/tunnels' | jq -r '.tunnels[1].public_url')' >> $BASH_ENV | ||
- run: | ||
name: Run e2e tests | ||
command: make end-to-end-tests | ||
- run: | ||
name: Build image | ||
command: | | ||
if [ "${CIRCLE_BRANCH}" == "master" ]; then | ||
docker build -t hootsuite/atlantis:latest . | ||
fi | ||
- run: | ||
name: Push image | ||
command: | | ||
if [ "${CIRCLE_BRANCH}" == "master" ]; then | ||
docker login -e "$DOCKER_EMAIL" -u "$DOCKER_USER" -p "$DOCKER_PASSWORD" | ||
docker push hootsuite/atlantis:latest | ||
fi | ||
- run: | ||
name: Tag and push version if exists | ||
# work around until tags are properly supported | ||
# https://discuss.circleci.com/t/git-tag-deploys-in-2-0/9493/6 | ||
command: | | ||
if [ "${CIRCLE_BRANCH}" == "master" ]; then | ||
for TAG in $(git tag --contains $CIRCLE_SHA1); do | ||
docker tag hootsuite/atlantis:latest hootsuite/atlantis:$TAG | ||
docker push hootsuite/atlantis:$TAG | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ atlantis | |
*.iml | ||
.vscode | ||
atlantis.db | ||
output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FROM alpine:3.6 | ||
LABEL authors="Anubhav Mishra, Luke Kysow" | ||
LABEL maintainer="[email protected],[email protected]" | ||
|
||
# create atlantis user | ||
RUN addgroup atlantis && \ | ||
adduser -S -G atlantis atlantis | ||
|
||
ENV ATLANTIS_HOME_DIR=/home/atlantis | ||
|
||
# install atlantis dependencies | ||
ENV DUMB_INIT_VERSION=1.2.0 | ||
ENV GOSU_VERSION=1.10 | ||
RUN apk add --no-cache ca-certificates gnupg curl git unzip bash openssh libcap openssl && \ | ||
wget -O /bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_amd64 && \ | ||
chmod +x /bin/dumb-init && \ | ||
mkdir -p /tmp/build && \ | ||
cd /tmp/build && \ | ||
wget -O gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64" && \ | ||
wget -O gosu.asc "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64.asc" && \ | ||
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && \ | ||
gpg --batch --verify gosu.asc gosu && \ | ||
chmod +x gosu && \ | ||
cp gosu /bin && \ | ||
cd /tmp && \ | ||
rm -rf /tmp/build && \ | ||
apk del gnupg openssl && \ | ||
rm -rf /root/.gnupg && rm -rf /var/cache/apk/* | ||
|
||
# install terraform binaries | ||
ENV DEFAULT_TERRAFORM_VERSION=0.10.0 | ||
|
||
RUN AVAILABLE_TERRAFORM_VERSIONS="0.8.8 0.9.11 0.10.0" && \ | ||
for VERSION in ${AVAILABLE_TERRAFORM_VERSIONS}; do curl -LOk https://releases.hashicorp.com/terraform/${VERSION}/terraform_${VERSION}_linux_amd64.zip && \ | ||
mkdir -p /usr/local/bin/tf/versions/${VERSION} && \ | ||
unzip terraform_${VERSION}_linux_amd64.zip -d /usr/local/bin/tf/versions/${VERSION} && \ | ||
ln -s /usr/local/bin/tf/versions/${VERSION}/terraform /usr/local/bin/terraform${VERSION};rm terraform_${VERSION}_linux_amd64.zip;done && \ | ||
ln -s /usr/local/bin/tf/versions/${DEFAULT_TERRAFORM_VERSION}/terraform /usr/local/bin/terraform | ||
|
||
# copy binary | ||
COPY atlantis /usr/local/bin/atlantis | ||
|
||
# copy docker entrypoint | ||
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | ||
|
||
ENTRYPOINT ["docker-entrypoint.sh"] | ||
CMD ["server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/dumb-init /bin/sh | ||
set -e | ||
|
||
# Modified: https://github.com/hashicorp/docker-consul/blob/2c2873f9d619220d1eef0bc46ec78443f55a10b5/0.X/docker-entrypoint.sh | ||
|
||
# If the user is trying to run atlantis directly with some arguments, then | ||
# pass them to atlantis. | ||
if [ "${1:0:1}" = '-' ]; then | ||
set -- atlantis "$@" | ||
fi | ||
|
||
# Look for atlantis subcommands. | ||
if atlantis --help "$1" 2>&1 | grep -q "atlantis $1"; then | ||
# We can't use the return code to check for the existence of a subcommand, so | ||
# we have to use grep to look for a pattern in the help output. | ||
set -- atlantis "$@" | ||
fi | ||
|
||
# If we are running atlantis, make sure it executes as the proper user. | ||
if [ "$1" = 'atlantis' ]; then | ||
# If requested, set the capability to bind to privileged ports before | ||
# we drop to the non-root user. Note that this doesn't work with all | ||
# storage drivers (it won't work with AUFS). | ||
if [ ! -z ${ATLANTIS_ALLOW_PRIVILEGED_PORTS+x} ]; then | ||
setcap "cap_net_bind_service=+ep" /bin/atlantis | ||
fi | ||
|
||
set -- gosu atlantis "$@" | ||
fi | ||
|
||
exec "$@" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
# define architecture we want to build | ||
XC_ARCH=${XC_ARCH:-"386 amd64 arm"} | ||
XC_OS=${XC_OS:-linux darwin} | ||
XC_EXCLUDE_OSARCH="!darwin/arm !darwin/386" | ||
|
||
# clean up | ||
echo "-> running clean up...." | ||
rm -rf output/* | ||
|
||
if ! which gox > /dev/null; then | ||
echo "-> installing gox..." | ||
go get -u github.com/mitchellh/gox | ||
fi | ||
|
||
# build | ||
# we want to build statically linked binaries | ||
export CGO_ENABLED=0 | ||
echo "-> building..." | ||
gox \ | ||
-os="${XC_OS}" \ | ||
-arch="${XC_ARCH}" \ | ||
-osarch="${XC_EXCLUDE_OSARCH}" \ | ||
-output "output/{{.OS}}_{{.Arch}}/atlantis" \ | ||
. | ||
|
||
# Zip and copy to the dist dir | ||
echo "" | ||
echo "Packaging..." | ||
for PLATFORM in $(find ./output -mindepth 1 -maxdepth 1 -type d); do | ||
OSARCH=$(basename ${PLATFORM}) | ||
echo "--> ${OSARCH}" | ||
|
||
pushd $PLATFORM >/dev/null 2>&1 | ||
zip ../atlantis_${OSARCH}.zip ./* | ||
popd >/dev/null 2>&1 | ||
done | ||
|
||
echo "" | ||
echo "" | ||
echo "-----------------------------------" | ||
echo "Output:" | ||
ls -alh output/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
cd e2e/ | ||
|
||
# Download dependencies | ||
echo "Running 'make deps'" | ||
make deps | ||
|