2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-22 02:02:14 +00:00

Update Release

- Added images to `build/docker`
- Update `quickstart` script to be more functional
This commit is contained in:
Emerle, Ryan 2021-11-01 12:25:17 -04:00
parent f2db11e89a
commit c4d10a201e
No known key found for this signature in database
GPG Key ID: C0D34C592AED41CE
22 changed files with 476 additions and 475 deletions

View File

@ -28,4 +28,4 @@ jobs:
- name: Codecov - name: Codecov
uses: codecov/codecov-action@v1 uses: codecov/codecov-action@v1
with: with:
fail_ci_if_error: true # optional (default = false) fail_ci_if_error: true

View File

@ -5,8 +5,7 @@ name: Microsite
on: on:
push: push:
branches: branches: [ 'master', 'main' ]
- master
jobs: jobs:
site: site:

View File

@ -1,17 +1,19 @@
REST_PORT=9000 # Portal settings
# portal settings
PORTAL_PORT=9001 PORTAL_PORT=9001
PLAY_HTTP_SECRET_KEY=change-this-for-prod PLAY_HTTP_SECRET_KEY=change-this-for-prod
VINYLDNS_BACKEND_URL=http://vinyldns-integration:9000 VINYLDNS_BACKEND_URL=http://vinyldns-api:9000
LDAP_PROVIDER_URL=ldap://vinyldns-ldap:19004
TEST_LOGIN=false
# API Settings
REST_PORT=9000
SQS_ENDPOINT=http://vinyldns-integration:19003 SQS_ENDPOINT=http://vinyldns-integration:19003
SNS_SERVICE_ENDPOINT=http://vinyldns-integration:19003
MYSQL_ENDPOINT=vinyldns-integration:19002 MYSQL_ENDPOINT=vinyldns-integration:19002
TEST_LOGIN=true DEFAULT_DNS_ADDRESS=vinyldns-integration:19001
JDBC_DRIVER=org.mariadb.jdbc.Driver JDBC_DRIVER=org.mariadb.jdbc.Driver
JDBC_URL=jdbc:mariadb://vinyldns-integration:19002/vinyldns?user=root&password=pass JDBC_URL=jdbc:mariadb://vinyldns-integration:19002/vinyldns?user=root&password=pass
JDBC_MIGRATION_URL=jdbc:mariadb://vinyldns-integration:19002/?user=root&password=pass JDBC_MIGRATION_URL=jdbc:mariadb://vinyldns-integration:19002/?user=root&password=pass
JDBC_USER=root JDBC_USER=root
JDBC_PASSWORD=pass JDBC_PASSWORD=pass
DEFAULT_DNS_ADDRESS=127.0.0.1:19001

View File

@ -1,6 +0,0 @@
-Xms512M
-Xmx1024M
-Xss2M
-XX:MaxMetaspaceSize=512M
-XX:ReservedCodeCacheSize=512M
-Djava.net.preferIPv4Stack=true

View File

@ -1,31 +1,36 @@
FROM hseeberger/scala-sbt:11.0.8_1.3.13_2.11.12 as builder # Build VinylDNS API if the JAR doesn't already exist
FROM vinyldns/build:base-build as base-build
COPY . /build/
WORKDIR /build
ARG BRANCH=master ## Run the build if we don't already have a vinyldns.jar
ARG VINYLDNS_VERSION RUN mkdir -p /opt/vinyldns/conf && \
if [ -f assembly/vinyldns.jar ]; then cp assembly/vinyldns.jar /opt/vinyldns/; fi && \
RUN git clone -b ${BRANCH} --single-branch --depth 1 https://github.com/vinyldns/vinyldns.git /vinyldns if [ ! -f /opt/vinyldns/vinyldns.jar ]; then \
env SBT_OPTS="-XX:+UseConcMarkSweepGC -Xmx4G -Xms1G" \
# The default jvmopts are huge, meant for running everything, use a paired down version sbt -Dbuild.scalafmtOnCompile=false -Dbuild.lintOnCompile=fase ";project api;coverageOff;assembly" \
COPY .jvmopts /vinyldns && cp assembly/vinyldns.jar /opt/vinyldns/; \
fi
RUN cd /vinyldns ; sbt "set version in ThisBuild := \"${VINYLDNS_VERSION}\"" api/stage
FROM adoptopenjdk/openjdk11:jdk-11.0.8_10-alpine FROM adoptopenjdk/openjdk11:jdk-11.0.8_10-alpine
ARG DOCKER_FILE_PATH
RUN apk add --update --no-cache netcat-openbsd bash
COPY --from=builder /vinyldns/modules/api/target/universal/stage /opt/docker
# This will set the vinyldns version, make sure to have this in config... version = ${?VINYLDNS_VERSION}
ARG VINYLDNS_VERSION ARG VINYLDNS_VERSION
ENV VINYLDNS_VERSION=$VINYLDNS_VERSION
RUN mkdir -p /opt/docker/lib_extra RUN apk add --update --no-cache bash && mkdir -p /opt/vinyldns/lib_extra
COPY --from=base-build /opt/vinyldns /opt/vinyldns
COPY ${DOCKER_FILE_PATH}/application.conf /opt/vinyldns/conf
COPY ${DOCKER_FILE_PATH}/logback.xml /opt/vinyldns/conf
RUN echo "${VINYLDNS_VERSION}" > /opt/vinyldns/conf/version
# Mount the volume for config file and lib extras # Mount the volume for config file and lib extras
# Note: These volume names are used in the build.sbt VOLUME ["/opt/vinyldns/lib_extra/", "/opt/vinyldns/conf/"]
VOLUME ["/opt/docker/lib_extra/", "/opt/docker/conf"]
EXPOSE 9000 EXPOSE 9000
ENTRYPOINT ["/opt/docker/bin/api"] ENTRYPOINT ["/bin/bash", "-c", "java -Dconfig.file=/opt/vinyldns/conf/application.conf \
-Dlogback.configurationFile=/opt/vinyldns/conf/logback.xml \
-Dvinyldns.version=$(cat /opt/vinyldns/conf/version) \
-cp /opt/vinyldns/lib_extra/* \
-jar /opt/vinyldns/vinyldns.jar" ]

49
build/docker/api/Makefile Normal file
View File

@ -0,0 +1,49 @@
SHELL=bash
IMAGE_TAG=$(shell awk -F'"' '{print $$2}' ../../../version.sbt)
IMAGE_NAME=vinyldns/api
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# Check that the required version of make is being used
REQ_MAKE_VER:=3.82
ifneq ($(REQ_MAKE_VER),$(firstword $(sort $(MAKE_VERSION) $(REQ_MAKE_VER))))
$(error The version of MAKE $(REQ_MAKE_VER) or higher is required; you are running $(MAKE_VERSION))
endif
# Extract arguments for `make run`
EXTRACT_ARGS=true
ifeq (run,$(firstword $(MAKECMDGOALS)))
EXTRACT_ARGS=true
endif
ifeq ($(EXTRACT_ARGS),true)
# use the rest as arguments for "run"
WITH_ARGS ?= $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
endif
ifdef $(WITH_ARGS)
ARG_SEPARATOR=--
endif
%:
@:
.ONESHELL:
.PHONY: all build run publish
all: build run
build:
@set -euo pipefail
cd ../../..
docker build $(BUILD_ARGS) --build-arg DOCKER_FILE_PATH="$$(realpath --relative-to="." "$(ROOT_DIR)")" --build-arg VINYLDNS_VERSION="$(IMAGE_TAG)" -t $(IMAGE_NAME):$(IMAGE_TAG) -f "$(ROOT_DIR)/Dockerfile" .
docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_NAME):latest
run:
@set -euo pipefail
docker network create --driver bridge vinyldns_net &> /dev/null || true
docker run -it --rm --env-file "$(ROOT_DIR)/../.env" --network vinyldns_net $(DOCKER_PARAMS) -v "$$(pwd)/:/opt/vinyldns/conf/" -p 9000:9000 $(IMAGE_NAME):$(IMAGE_TAG) $(ARG_SEPARATOR) $(WITH_ARGS)
publish: build
@set -euo pipefail
DOCKER_CONTENT_TRUST=1 docker push $(IMAGE_NAME):$(IMAGE_TAG)
DOCKER_CONTENT_TRUST=1 docker push $(IMAGE_NAME):latest

View File

@ -1,48 +1,165 @@
vinyldns { vinyldns {
version = "unknown"
version = ${?VINYLDNS_VERSION} base-version = "0.0.0-local-dev"
version = ${vinyldns.base-version} # default to the base version if not overridden
version = ${?VINYLDNS_VERSION} # override the base version via env var
# How often to any particular zone can be synchronized in milliseconds
sync-delay = 10000
sync-delay = ${?SYNC_DELAY}
# If we should start up polling for change requests, set this to false for the inactive cluster
processing-disabled = false
processing-disabled = ${?PROCESSING_DISABLED}
# Number of records that can be in a zone
max-zone-size = 60000
max-zone-size = ${?MAX_ZONE_SIZE}
# Types of unowned records that users can access in shared zones
shared-approved-types = ["A", "AAAA", "CNAME", "PTR", "TXT"]
# Batch change settings
batch-change-limit = 1000
batch-change-limit = ${?BATCH_CHANGE_LIMIT}
manual-batch-review-enabled = true
manual-batch-review-enabled = ${?MANUAL_BATCH_REVIEW_ENABLED}
scheduled-changes-enabled = true
scheduled-changes-enabled = ${?SCHEDULED_CHANGES_ENABLED}
multi-record-batch-change-enabled = true
multi-record-batch-change-enabled = ${?MULTI_RECORD_BATCH_CHANGE_ENABLED}
# configured backend providers
backend {
# Use "default" when dns backend legacy = true
# otherwise, use the id of one of the connections in any of your backends
default-backend-id = "default"
# this is where we can save additional backends
backend-providers = [
{
class-name = "vinyldns.api.backend.dns.DnsBackendProviderLoader"
settings = {
legacy = false
backends = [
{
id = "default"
zone-connection = {
name = "vinyldns."
key-name = "vinyldns."
key-name = ${?DEFAULT_DNS_KEY_NAME}
key = "nzisn+4G2ldMn0q1CV3vsg=="
key = ${?DEFAULT_DNS_KEY_SECRET}
primary-server = "127.0.0.1"
primary-server = ${?DEFAULT_DNS_ADDRESS}
}
transfer-connection = {
name = "vinyldns."
key-name = "vinyldns."
key-name = ${?DEFAULT_DNS_KEY_NAME}
key = "nzisn+4G2ldMn0q1CV3vsg=="
key = ${?DEFAULT_DNS_KEY_SECRET}
primary-server = "127.0.0.1"
primary-server = ${?DEFAULT_DNS_ADDRESS}
},
tsig-usage = "always"
},
{
id = "func-test-backend"
zone-connection = {
name = "vinyldns."
key-name = "vinyldns."
key-name = ${?DEFAULT_DNS_KEY_NAME}
key = "nzisn+4G2ldMn0q1CV3vsg=="
key = ${?DEFAULT_DNS_KEY_SECRET}
primary-server = "127.0.0.1"
primary-server = ${?DEFAULT_DNS_ADDRESS}
}
transfer-connection = {
name = "vinyldns."
key-name = "vinyldns."
key-name = ${?DEFAULT_DNS_KEY_NAME}
key = "nzisn+4G2ldMn0q1CV3vsg=="
key = ${?DEFAULT_DNS_KEY_SECRET}
primary-server = "127.0.0.1"
primary-server = ${?DEFAULT_DNS_ADDRESS}
},
tsig-usage = "always"
}
]
}
}
]
}
queue { queue {
class-name = "vinyldns.mysql.queue.MySqlMessageQueueProvider" class-name = "vinyldns.sqs.queue.SqsMessageQueueProvider"
polling-interval = 250.millis
messages-per-poll = 10 messages-per-poll = 10
polling-interval = 250.millis
settings {
# AWS access key and secret.
access-key = "test"
access-key = ${?AWS_ACCESS_KEY}
secret-key = "test"
secret-key = ${?AWS_SECRET_ACCESS_KEY}
# Regional endpoint to make your requests (eg. 'us-west-2', 'us-east-1', etc.). This is the region where your queue is housed.
signing-region = "us-east-1"
signing-region = ${?SQS_REGION}
# Endpoint to access queue
service-endpoint = "http://vinyldns-integration:19003/"
service-endpoint = ${?SQS_SERVICE_ENDPOINT}
# Queue name. Should be used in conjunction with service endpoint, rather than using a queue url which is subject to change.
queue-name = "vinyldns"
queue-name = ${?SQS_QUEUE_NAME}
}
}
email {
class-name = "vinyldns.api.notifier.email.EmailNotifierProvider"
class-name = ${?EMAIL_CLASS_NAME}
settings = { settings = {
name = "vinyldns" from = "VinylDNS <do-not-reply@vinyldns.io>"
name = ${?JDBC_DB_NAME} }
driver = "org.mariadb.jdbc.Driver" }
driver = ${?JDBC_DRIVER}
migration-url = "jdbc:mariadb://vinyldns-integration:19002/?user=root&password=pass"
migration-url = ${?JDBC_MIGRATION_URL}
url = "jdbc:mariadb://vinyldns-integration:19002/vinyldns?user=root&password=pass"
url = ${?JDBC_URL}
user = "root"
user = ${?JDBC_USER}
password = "pass"
password = ${?JDBC_PASSWORD}
# see https://github.com/brettwooldridge/HikariCP sns {
connection-timeout-millis = 1000 class-name = "vinyldns.apadi.notifier.sns.SnsNotifierProvider"
idle-timeout = 10000 class-name = ${?SNS_CLASS_NAME}
max-lifetime = 30000 settings {
maximum-pool-size = 5 topic-arn = "arn:aws:sns:us-east-1:000000000000:batchChanges"
minimum-idle = 0 topic-arn = ${?SNS_TOPIC_ARN}
access-key = "test"
my-sql-properties = { access-key = ${?SNS_ACCESS_KEY}
cachePrepStmts=true secret-key = "test"
prepStmtCacheSize=250 secret-key = ${?SNS_SECRET_KEY}
prepStmtCacheSqlLimit=2048 service-endpoint = "http://vinyldns-integration:19003"
rewriteBatchedStatements=true service-endpoint = ${?SNS_SERVICE_ENDPOINT}
} signing-region = "us-east-1"
signing-region = ${?SNS_REGION}
} }
} }
rest { rest {
host = "0.0.0.0" host = "0.0.0.0"
port = 9000 port = 9000
port=${?API_SERVICE_PORT}
} }
sync-delay = 10000
approved-name-servers = [
"172.17.42.1.",
"ns1.parent.com."
"ns1.parent.com1."
"ns1.parent.com2."
"ns1.parent.com3."
"ns1.parent.com4."
]
crypto { crypto {
type = "vinyldns.core.crypto.NoOpCrypto" type = "vinyldns.core.crypto.NoOpCrypto"
@ -56,16 +173,16 @@ vinyldns {
# these must be overridden to use MYSQL for production use # these must be overridden to use MYSQL for production use
# assumes a docker or mysql instance running locally # assumes a docker or mysql instance running locally
name = "vinyldns" name = "vinyldns"
name = ${?JDBC_DB_NAME} name = ${?DATABASE_NAME}
driver = "org.mariadb.jdbc.Driver" driver = "org.h2.Driver"
driver = ${?JDBC_DRIVER} driver = ${?JDBC_DRIVER}
migration-url = "jdbc:mariadb://vinyldns-integration:19002/?user=root&password=pass" migration-url = "jdbc:h2:mem:vinyldns;MODE=MYSQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=TRUE;IGNORECASE=TRUE;INIT=RUNSCRIPT FROM 'classpath:test/ddl.sql'"
migration-url = ${?JDBC_MIGRATION_URL} migration-url = ${?JDBC_MIGRATION_URL}
url = "jdbc:mariadb://vinyldns-integration:19002/vinyldns?user=root&password=pass" url = "jdbc:h2:mem:vinyldns;MODE=MYSQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=TRUE;IGNORECASE=TRUE;INIT=RUNSCRIPT FROM 'classpath:test/ddl.sql'"
url = ${?JDBC_URL} url = ${?JDBC_URL}
user = "root" user = "sa"
user = ${?JDBC_USER} user = ${?JDBC_USER}
password = "pass" password = ""
password = ${?JDBC_PASSWORD} password = ${?JDBC_PASSWORD}
# see https://github.com/brettwooldridge/HikariCP # see https://github.com/brettwooldridge/HikariCP
connection-timeout-millis = 1000 connection-timeout-millis = 1000
@ -78,71 +195,37 @@ vinyldns {
# Repositories that use this data store are listed here # Repositories that use this data store are listed here
repositories { repositories {
zone { zone {
# no additional settings for now
} }
batch-change { batch-change {
# no additional settings for now
} }
user { user {
} }
record-set { record-set {
}
zone-change {
}
record-change {
} }
group { group {
}
group-change {
} }
membership { membership {
}
group-change {
}
zone-change {
}
record-change {
} }
} }
} }
defaultZoneConnection { backends = []
name = "vinyldns."
keyName = "vinyldns."
keyName = ${?DEFAULT_DNS_KEY_NAME}
key = "nzisn+4G2ldMn0q1CV3vsg=="
key = ${?DEFAULT_DNS_KEY_SECRET}
primaryServer = "vinyldns-integration:19001"
primaryServer = ${?DEFAULT_DNS_ADDRESS}
}
defaultTransferConnection {
name = "vinyldns."
keyName = "vinyldns."
keyName = ${?DEFAULT_DNS_KEY_NAME}
key = "nzisn+4G2ldMn0q1CV3vsg=="
key = ${?DEFAULT_DNS_KEY_SECRET}
primaryServer = "vinyldns-integration:19001"
primaryServer = ${?DEFAULT_DNS_ADDRESS}
}
backends = [
{
id = "func-test-backend"
zone-connection {
name = "vinyldns."
key-name = "vinyldns."
key-name = ${?DEFAULT_DNS_KEY_NAME}
key = "nzisn+4G2ldMn0q1CV3vsg=="
key = ${?DEFAULT_DNS_KEY_SECRET}
primary-server = "vinyldns-integration:19001"
primary-server = ${?DEFAULT_DNS_ADDRESS}
}
transfer-connection {
name = "vinyldns."
key-name = "vinyldns."
key-name = ${?DEFAULT_DNS_KEY_NAME}
key = "nzisn+4G2ldMn0q1CV3vsg=="
key = ${?DEFAULT_DNS_KEY_SECRET}
primary-server = "vinyldns-integration:19001"
primary-server = ${?DEFAULT_DNS_ADDRESS}
}
}
]
batch-change-limit = 1000
# FQDNs / IPs that cannot be modified via VinylDNS # FQDNs / IPs that cannot be modified via VinylDNS
# regex-list used for all record types except PTR # regex-list used for all record types except PTR
@ -152,6 +235,7 @@ vinyldns {
"high-value-domain.*" # for testing "high-value-domain.*" # for testing
] ]
ip-list = [ ip-list = [
# using reverse zones in the vinyldns/bind9 docker image for testing
"192.0.2.252", "192.0.2.252",
"192.0.2.253", "192.0.2.253",
"fd69:27cc:fe91:0:0:0:0:ffff", "fd69:27cc:fe91:0:0:0:0:ffff",
@ -159,10 +243,78 @@ vinyldns {
] ]
} }
# types of unowned records that users can access in shared zones # FQDNs / IPs / zone names that require manual review upon submission in batch change interface
shared-approved-types = ["A", "AAAA", "CNAME", "PTR", "TXT"] # domain-list used for all record types except PTR
# ip-list used exclusively for PTR records
manual-review-domains = {
domain-list = [
"needs-review.*"
]
ip-list = [
"192.0.1.254",
"192.0.1.255",
"192.0.2.254",
"192.0.2.255",
"192.0.3.254",
"192.0.3.255",
"192.0.4.254",
"192.0.4.255",
"fd69:27cc:fe91:0:0:0:ffff:1",
"fd69:27cc:fe91:0:0:0:ffff:2",
"fd69:27cc:fe92:0:0:0:ffff:1",
"fd69:27cc:fe92:0:0:0:ffff:2",
"fd69:27cc:fe93:0:0:0:ffff:1",
"fd69:27cc:fe93:0:0:0:ffff:2",
"fd69:27cc:fe94:0:0:0:ffff:1",
"fd69:27cc:fe94:0:0:0:ffff:2"
]
zone-name-list = [
"zone.requires.review."
"zone.requires.review1."
"zone.requires.review2."
"zone.requires.review3."
"zone.requires.review4."
]
}
manual-batch-review-enabled = true # FQDNs / IPs that cannot be modified via VinylDNS
# regex-list used for all record types except PTR
# ip-list used exclusively for PTR records
high-value-domains = {
regex-list = [
"high-value-domain.*" # for testing
]
ip-list = [
# using reverse zones in the vinyldns/bind9 docker image for testing
"192.0.1.252",
"192.0.1.253",
"192.0.2.252",
"192.0.2.253",
"192.0.3.252",
"192.0.3.253",
"192.0.4.252",
"192.0.4.253",
"fd69:27cc:fe91:0:0:0:0:ffff",
"fd69:27cc:fe91:0:0:0:ffff:0",
"fd69:27cc:fe92:0:0:0:0:ffff",
"fd69:27cc:fe92:0:0:0:ffff:0",
"fd69:27cc:fe93:0:0:0:0:ffff",
"fd69:27cc:fe93:0:0:0:ffff:0",
"fd69:27cc:fe94:0:0:0:0:ffff",
"fd69:27cc:fe94:0:0:0:ffff:0"
]
}
global-acl-rules = [
{
group-ids: ["global-acl-group-id"],
fqdn-regex-list: [".*shared[0-9]{1}."]
},
{
group-ids: ["another-global-acl-group"],
fqdn-regex-list: [".*ok[0-9]{1}."]
}
]
} }
akka { akka {

View File

@ -1,59 +0,0 @@
version: "3.0"
services:
api:
build:
context: ./api
image: "vinyldns/api:${VINYLDNS_VERSION}"
container_name: "vinyldns-api"
environment:
MYSQL_ROOT_PASSWORD: 'pass'
MYSQL_ROOT_HOST: '%'
logging:
driver: none
ports:
- "9000:9000"
volumes:
- ./api/application.conf:/opt/docker/conf/application.conf
- ./api/logback.xml:/opt/docker/conf/logback.xml
depends_on:
- integration
ldap:
container_name: "vinyldns-ldap"
image: vinyldns/build:openldap
ports:
- "19004:19004"
integration:
container_name: "vinyldns-api-integration"
hostname: "vinyldns-integration"
image: "vinyldns-api-integration"
build:
context: ../
dockerfile: test/api/integration/Dockerfile
environment:
RUN_SERVICES: "deps-only tail-logs"
env_file:
.env
ports:
- "19001-19003:19001-19003/tcp"
- "19001:19001/udp"
portal:
build:
context: ./portal
image: "vinyldns/portal:${VINYLDNS_VERSION}"
container_name: "vinyldns-portal"
environment:
MYSQL_ROOT_PASSWORD: 'pass'
MYSQL_ROOT_HOST: '%'
logging:
driver: none
ports:
- "9001:9000"
volumes:
- ./portal/application.conf:/opt/docker/conf/application.conf
depends_on:
- api
- ldap

View File

@ -1,130 +0,0 @@
#!/bin/bash
CURDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function usage() {
printf "usage: docker-release.sh [OPTIONS]\n\n"
printf "builds and releases vinyldns artifacts\n\n"
printf "options:\n"
printf "\t-b, --branch: the branch of tag to use for the build; default is master\n"
printf "\t-c, --clean: indicates a fresh build or attempt to work with existing images; default is off\n"
printf "\t-l, --latest: indicates docker will tag image with latest; default is off\n"
printf "\t-p, --push: indicates docker will push to the repository; default is off\n"
printf "\t-r, --repository [REPOSITORY]: the docker repository where this image will be pushed; default is docker.io\n"
printf "\t-t, --tag [TAG]: sets the qualifier for the semver version; default is to not use a build tag\n"
printf "\t-v, --version [VERSION]: overrides version calculation and forces the version specified\n"
}
# Default the build to -SNAPSHOT if not set
BUILD_TAG=
REPOSITORY="docker.io"
DOCKER_PUSH=0
DO_BUILD=0
BRANCH="master"
V=
TAG_LATEST=0
while [ "$1" != "" ]; do
case "$1" in
-b | --branch)
BRANCH="$2"
shift 2
;;
-c | --clean)
DO_BUILD=1
shift
;;
-l | --latest)
TAG_LATEST=1
shift
;;
-p | --push)
DOCKER_PUSH=1
shift
;;
-r | --repository)
REPOSITORY="$2"
shift 2
;;
-t | --tag)
BUILD_TAG="-b$2"
shift 2
;;
-v | --version)
V="$2"
shift 2
;;
*)
usage
exit
;;
esac
done
BASEDIR=$CURDIR/../
# Clear out our target
rm -rf $CURDIR/target && mkdir -p $CURDIR/target
# Download just the version.sbt file from the branch specified, we use this to calculate the version
wget "https://raw.githubusercontent.com/vinyldns/vinyldns/${BRANCH}/version.sbt" -P "${CURDIR}/target"
if [ -z "$V" ]; then
# Calculate the version by using version.sbt, this will pull out something like 0.9.4
V=$(find $CURDIR/target -name "version.sbt" | head -n1 | xargs grep "[ \\t]*version in ThisBuild :=" | head -n1 | sed 's/.*"\(.*\)".*/\1/')
echo "VERSION ON BRANCH ${BRANCH} IS ${V}"
VINYLDNS_VERSION=
if [[ "$V" == *-SNAPSHOT ]]; then
if [ -z "$BUILD_TAG" ]; then
# build tag is not defined, so assume -SNAPSHOT
VINYLDNS_VERSION="$V"
else
# build tag IS defined, drop the SNAPSHOT and append the build tag
VINYLDNS_VERSION="${V%?????????}${BUILD_TAG}"
fi
else
# NOT a -SNAPSHOT, append the build tag if there is one otherwise it will be empty!
VINYLDNS_VERSION="$V${BUILD_TAG}"
fi
else
VINYLDNS_VERSION="$V"
fi
export VINYLDNS_VERSION=$VINYLDNS_VERSION
echo "VINYLDNS VERSION BEING RELEASED IS $VINYLDNS_VERSION"
if [ $DO_BUILD -eq 1 ]; then
docker-compose -f "${CURDIR}/docker-compose.yml" build \
--no-cache \
--parallel \
--build-arg VINYLDNS_VERSION="${VINYLDNS_VERSION}" \
--build-arg BRANCH="${BRANCH}"
if [ $? -eq 0 ]; then
# Runs smoke tests to make sure the new images are sound
docker-compose -f "${CURDIR}/docker-compose.yml" --log-level ERROR up --exit-code-from functest
fi
if [ $? -eq 0 ]; then
docker tag vinyldns/api:$VINYLDNS_VERSION $REPOSITORY/vinyldns/api:$VINYLDNS_VERSION
docker tag vinyldns/portal:$VINYLDNS_VERSION $REPOSITORY/vinyldns/portal:$VINYLDNS_VERSION
if [ $TAG_LATEST -eq 1 ]; then
echo "Tagging latest..."
docker tag vinyldns/api:$VINYLDNS_VERSION $REPOSITORY/vinyldns/api:latest
docker tag vinyldns/portal:$VINYLDNS_VERSION $REPOSITORY/vinyldns/portal:latest
fi
fi
fi
if [ $DOCKER_PUSH -eq 1 ]; then
docker push $REPOSITORY/vinyldns/api:$VINYLDNS_VERSION
docker push $REPOSITORY/vinyldns/portal:$VINYLDNS_VERSION
if [ $TAG_LATEST -eq 1 ]; then
echo "Pushing latest..."
docker push $REPOSITORY/vinyldns/api:latest
docker push $REPOSITORY/vinyldns/portal:latest
fi
fi

View File

@ -1,6 +0,0 @@
-Xms512M
-Xmx1024M
-Xss2M
-XX:MaxMetaspaceSize=512M
-XX:ReservedCodeCacheSize=512M
-Djava.net.preferIPv4Stack=true

View File

@ -1,34 +1,37 @@
FROM vinyldns/build:base-build-portal as builder FROM vinyldns/build:base-build-portal as builder
ARG BRANCH=master
ARG VINYLDNS_VERSION ARG VINYLDNS_VERSION
RUN git clone -b ${BRANCH} --single-branch --depth 1 https://github.com/vinyldns/vinyldns.git /vinyldns COPY . /vinyldns
# The default jvmopts are huge, meant for running everything, use a paired down version WORKDIR /vinyldns
COPY .jvmopts /vinyldns RUN cp /build/node_modules.tar.xz /vinyldns/modules/portal && \
cd /vinyldns/modules/portal && tar Jxf node_modules.tar.xz && \
cd /vinyldns
RUN cd /vinyldns ; sbt "set version in ThisBuild := \"${VINYLDNS_VERSION}\"" portal/preparePortal universal:packageZipTarball RUN sbt "set version in ThisBuild := \"${VINYLDNS_VERSION}\"; project portal; preparePortal"
RUN sbt "set version in ThisBuild := \"${VINYLDNS_VERSION}\"; project portal; universal:packageZipTarball"
FROM adoptopenjdk/openjdk11:jdk-11.0.8_10-alpine FROM adoptopenjdk/openjdk11:jdk-11.0.8_10-alpine
ARG DOCKER_FILE_PATH
ARG VINYLDNS_VERSION
RUN apk add --update --no-cache netcat-openbsd bash RUN test -n "VINYLDNS_VERSION" || (echo "VINYLDNS_VERSION not set" && false)
COPY --from=builder /vinyldns/modules/portal/target/universal/portal.tgz / COPY --from=builder /vinyldns/modules/portal/target/universal/portal.tgz /
RUN mkdir -p /opt && \ RUN apk add --update --no-cache bash && \
tar -xzvf /portal.tgz && \ mkdir -p /opt/vinyldns/lib_extra && \
mv /portal /opt/docker && \ tar -xzf /portal.tgz && \
mkdir -p /opt/docker/lib_extra rm /portal.tgz && \
mv /portal/* /opt/vinyldns && \
echo "${VINYLDNS_VERSION}" > /opt/vinyldns/conf/version
# This will set the vinyldns version, make sure to have this in config... version = ${?VINYLDNS_VERSION} COPY ${DOCKER_FILE_PATH}/application.conf /opt/vinyldns/conf/
ARG VINYLDNS_VERSION
ENV VINYLDNS_VERSION=$VINYLDNS_VERSION
# Mount the volume for config file and lib extras VOLUME ["/opt/vinyldns/lib_extra/", "/opt/vinyldns/conf/"]
# Note: These volume names are used in the build.sbt
VOLUME ["/opt/docker/lib_extra/", "/opt/docker/conf"]
EXPOSE 9000 EXPOSE 9001
ENTRYPOINT ["/opt/docker/bin/portal"] ENTRYPOINT ["/bin/bash","-c", "java -Dvinyldns.version=$(cat /opt/vinyldns/conf/version) \
-Dconfig.file=/opt/vinyldns/conf/application.conf \
-cp /opt/vinyldns/conf:/opt/vinyldns/lib/*:/opt/vinyldns/lib_extra/* \
play.core.server.ProdServerStart"]

View File

@ -0,0 +1,53 @@
SHELL=bash
IMAGE_TAG=$(shell awk -F'"' '{print $$2}' ../../../version.sbt)
IMAGE_NAME=vinyldns/portal
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# Check that the required version of make is being used
REQ_MAKE_VER:=3.82
ifneq ($(REQ_MAKE_VER),$(firstword $(sort $(MAKE_VERSION) $(REQ_MAKE_VER))))
$(error The version of MAKE $(REQ_MAKE_VER) or higher is required; you are running $(MAKE_VERSION))
endif
# Extract arguments for `make run`
EXTRACT_ARGS=true
ifeq (run,$(firstword $(MAKECMDGOALS)))
EXTRACT_ARGS=true
endif
ifeq ($(EXTRACT_ARGS),true)
# use the rest as arguments for "run"
WITH_ARGS ?= $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
endif
ifdef $(WITH_ARGS)
ARG_SEPARATOR=--
endif
%:
@:
.ONESHELL:
.PHONY: all build run
all: build run
.PHONY: all build run publish
all: build run
build:
@set -euo pipefail
cd ../../..
docker build $(BUILD_ARGS) --build-arg DOCKER_FILE_PATH="$$(realpath --relative-to="." "$(ROOT_DIR)")" --build-arg VINYLDNS_VERSION="$(IMAGE_TAG)" -t $(IMAGE_NAME):$(IMAGE_TAG) -f "$(ROOT_DIR)/Dockerfile" .
docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_NAME):latest
run:
@set -euo pipefail
docker network create --driver bridge vinyldns_net &> /dev/null || true
docker run -it --rm --network vinyldns_net --env-file "$(ROOT_DIR)/../.env" $(DOCKER_PARAMS) -v "$$(pwd)/application.conf:/opt/vinyldns/conf/application.conf" -p 9001:9001 $(IMAGE_NAME):$(IMAGE_TAG) $(ARG_SEPARATOR) $(WITH_ARGS)
publish: build
@set -euo pipefail
DOCKER_CONTENT_TRUST=1 docker push $(IMAGE_NAME):$(IMAGE_TAG)
DOCKER_CONTENT_TRUST=1 docker push $(IMAGE_NAME):latest

View File

@ -11,7 +11,7 @@ LDAP {
# This will be the name of the LDAP field that carries the user's login id (what they enter in the username in login form) # This will be the name of the LDAP field that carries the user's login id (what they enter in the username in login form)
userNameAttribute = "uid" userNameAttribute = "uid"
# For ogranization, leave empty for this demo, the domainName is what matters, and that is the LDAP structure # For organization, leave empty for this demo, the domainName is what matters, and that is the LDAP structure
# to search for users that require login # to search for users that require login
searchBase = [ searchBase = [
{organization = "", domainName = "ou=people,dc=planetexpress,dc=com"}, {organization = "", domainName = "ou=people,dc=planetexpress,dc=com"},
@ -38,41 +38,15 @@ crypto {
type = "vinyldns.core.crypto.NoOpCrypto" type = "vinyldns.core.crypto.NoOpCrypto"
} }
http.port = 9000 http.port = 9001
http.port = ${?PORTAL_PORT}
data-stores = ["mysql"] data-stores = ["mysql"]
portal.vinyldns.backend.url = "http://vinyldns-integration:9000"
portal.vinyldns.backend.url = ${?API_URL}
# Note: The default mysql settings assume a local docker compose setup with mysql named vinyldns-mysql # Note: The default mysql settings assume a local docker compose setup with mysql named vinyldns-mysql
# follow the configuration guide to point to your mysql # follow the configuration guide to point to your mysql
# Only 3 repositories are needed for portal: user, task, user-change # Only 3 repositories are needed for portal: user, task, user-change
mysql { mysql {
settings {
# JDBC Settings, these are all values in scalikejdbc-config, not our own
# these must be overridden to use MYSQL for production use
# assumes a docker or mysql instance running locally
name = "vinyldns"
driver = "org.mariadb.jdbc.Driver"
migration-url = "jdbc:mariadb://vinyldns-integration:19002/?user=root&password=pass"
migration-url = ${?JDBC_MIGRATION_URL}
url = "jdbc:mariadb://vinyldns-integration:19002/vinyldns?user=root&password=pass"
url = ${?JDBC_URL}
user = "root"
user = ${?JDBC_USER}
password = "pass"
password = ${?JDBC_PASSWORD}
# see https://github.com/brettwooldridge/HikariCP
connection-timeout-millis = 1000
idle-timeout = 10000
max-lifetime = 600000
maximum-pool-size = 20
minimum-idle = 20
register-mbeans = true
}
repositories { repositories {
user { user {
} }
@ -85,6 +59,4 @@ mysql {
# You generate this yourself following https://www.playframework.com/documentation/2.7.x/ApplicationSecret # You generate this yourself following https://www.playframework.com/documentation/2.7.x/ApplicationSecret
play.http.secret.key = "rpkTGtoJvLIdIV?WU=0@yW^x:pcEGyAt`^p/P3G0fpbj9:uDnD@caSjCDqA0@tB=" play.http.secret.key = "rpkTGtoJvLIdIV?WU=0@yW^x:pcEGyAt`^p/P3G0fpbj9:uDnD@caSjCDqA0@tB="
play.http.secret.key = ${?PLAY_HTTP_SECRET_KEY}
vinyldns.version = "unknown"
vinyldns.version = ${?VINYLDNS_VERSION}

View File

@ -1,70 +0,0 @@
#!/bin/bash
CURDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function usage() {
printf "usage: start.sh [OPTIONS]\n\n"
printf "starts a specific version of vinyldns\n\n"
printf "options:\n"
printf "\t-v, --version: the version to start up; required\n"
}
function wait_for_url() {
echo -n "Checking ${URL}..."
RETRY="$TIMEOUT"
while [ "$RETRY" -gt 0 ]; do
if curl -I -s "${URL}" -o /dev/null -w "%{http_code}" &>/dev/null || false; then
echo "Succeeded in connecting to ${URL}!"
break
else
echo -n "."
((RETRY -= 1))
sleep 1
if [ "$RETRY" -eq 0 ]; then
echo "Exceeded retries waiting for ${URL} to be ready, failing"
exit 1
fi
fi
done
}
# Default the build to -SNAPSHOT if not set
VINYLDNS_VERSION=
while [ "$1" != "" ]; do
case "$1" in
-v | --version)
VINYLDNS_VERSION="$2"
shift 2
;;
*)
usage
exit
;;
esac
done
if [ -z "$VINYLDNS_VERSION" ]; then
echo "VINYLDNS_VERSION not set"
usage
exit
else
export VINYLDNS_VERSION=$VINYLDNS_VERSION
fi
# Actually starts up our docker images
docker-compose -f "${CURDIR}/docker/docker-compose.yml" up --no-build -d api portal
# Waits for the URL to be available
wait_for_url "http://localhost:9001"
if [ $? -eq 0 ]; then
echo "VinylDNS started and available at http://localhost:9001"
exit 0
else
echo "VinylDNS startup failed!"
"${CURDIR}/stop.sh"
exit 1
fi

View File

@ -1,5 +0,0 @@
#!/bin/bash
CURDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
docker-compose -f $CURDIR/docker/docker-compose.yml down

View File

@ -6,6 +6,7 @@ VINYLDNS_PORTAL_URL=http://localhost:9001
PORTAL_PORT=9001 PORTAL_PORT=9001
PLAY_HTTP_SECRET_KEY=change-this-for-prod PLAY_HTTP_SECRET_KEY=change-this-for-prod
VINYLDNS_BACKEND_URL=http://vinyldns-api:9000 VINYLDNS_BACKEND_URL=http://vinyldns-api:9000
LDAP_PROVIDER_URL=ldap://vinyldns-ldap:19004
TEST_LOGIN=false TEST_LOGIN=false
# API Settings # API Settings

View File

@ -26,10 +26,12 @@ The `quickstart-vinyldns.sh` script takes a number of optional arguments:
| Flag | Description | | Flag | Description |
|:---|:---| |:---|:---|
| -a, --api-only | do not start up the VinylDNS Portal| | `-a, --api-only` | do not start up the VinylDNS Portal" |
| -b, --build | force a rebuild of the Docker images with the local code| | `-b, --build` | force a rebuild of the Docker images with the local code" |
| -r, --reset | reset any the running containers| | `-c, --clean` | stops all VinylDNS containers" |
| -s, --service | specify the service to run| | `-d, --deps-only` | only start up the dependencies, not the API or Portal" |
| -t, --timeout | the time to wait (in seconds) for the portal and API to start (default: 60)| | `-r, --reset` | reset any the running containers" |
| -u, --update | remove the local quickstart images to force a re-pull from docker hub| | `-s, --service` | specify the service to run" |
| -v, --version-tag | specify Docker image tag version (default: latest)| | `-t, --timeout` | the time to wait (in seconds) for the Portal and API to start (default: 60)" |
| `-u, --update` | remove the local quickstart images to force a re-pull from Docker Hub" |
| `-v, --version-tag` | specify Docker image tag version (default: latest)" |

View File

@ -37,10 +37,12 @@ build:
run: run:
@set -euo pipefail @set -euo pipefail
docker run -it --rm $(DOCKER_PARAMS) -v "$$(pwd)/application.conf:/opt/vinyldns/conf/vinyldns.conf" -v "$$(pwd)/logback.xml:/opt/vinyldns/conf/logback.xml" -p 9000:9000 $(IMAGE_NAME) $(ARG_SEPARATOR) $(WITH_ARGS) docker network create --driver bridge vinyldns_net &> /dev/null || true
docker run -it --rm $(DOCKER_PARAMS) --network vinyldns_net -v "$$(pwd)/application.conf:/opt/vinyldns/conf/vinyldns.conf" -v "$$(pwd)/logback.xml:/opt/vinyldns/conf/logback.xml" -p 9000:9000 $(IMAGE_NAME) $(ARG_SEPARATOR) $(WITH_ARGS)
run-bg: run-bg:
@set -euo pipefail @set -euo pipefail
docker stop $(IMAGE_NAME) &> /dev/null || true docker stop $(IMAGE_NAME) &> /dev/null || true
docker rm $(IMAGE_NAME) &> /dev/null || true docker rm $(IMAGE_NAME) &> /dev/null || true
docker run -td --name $(IMAGE_NAME) --rm $(DOCKER_PARAMS) -v "$$(pwd)/application.conf:/opt/vinyldns/conf/vinyldns.conf" -v "$$(pwd)/logback.xml:/opt/vinyldns/conf/logback.xml" -p 9001:9001 $(IMAGE_NAME) -- /bin/bash docker network create --driver bridge vinyldns_net &> /dev/null || true
docker run -td --name $(IMAGE_NAME) --rm $(DOCKER_PARAMS) --network vinyldns_net -v "$$(pwd)/application.conf:/opt/vinyldns/conf/vinyldns.conf" -v "$$(pwd)/logback.xml:/opt/vinyldns/conf/logback.xml" -p 9001:9001 $(IMAGE_NAME) -- /bin/bash

View File

@ -5,7 +5,7 @@ COPY . /vinyldns
WORKDIR /vinyldns WORKDIR /vinyldns
RUN cp /build/node_modules.tar.xz /vinyldns/modules/portal && \ RUN cp /build/node_modules.tar.xz /vinyldns/modules/portal && \
cd /vinyldns/modules/portal && tar Jxvf node_modules.tar.xz && \ cd /vinyldns/modules/portal && tar Jxf node_modules.tar.xz && \
cd /vinyldns cd /vinyldns
RUN sbt "set version in ThisBuild := \"${VINYLDNS_VERSION}\"; project portal; preparePortal" RUN sbt "set version in ThisBuild := \"${VINYLDNS_VERSION}\"; project portal; preparePortal"
@ -18,7 +18,7 @@ RUN apk add --update --no-cache bash
COPY --from=builder /vinyldns/modules/portal/target/universal/portal.tgz / COPY --from=builder /vinyldns/modules/portal/target/universal/portal.tgz /
RUN mkdir -p /opt && \ RUN mkdir -p /opt && \
tar -xzvf /portal.tgz && \ tar -xzf /portal.tgz && \
mv /portal /opt/vinyldns && \ mv /portal /opt/vinyldns && \
mkdir -p /opt/vinyldns/lib_extra mkdir -p /opt/vinyldns/lib_extra

View File

@ -1,5 +1,6 @@
SHELL=bash SHELL=bash
IMAGE_NAME=vinyldns/portal:local-dev IMAGE_TAG=$(shell awk -F'"' '{print $$2}' ../../../version.sbt)
IMAGE_NAME=vinyldns/portal
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# Check that the required version of make is being used # Check that the required version of make is being used
@ -37,10 +38,12 @@ build:
run: run:
@set -euo pipefail @set -euo pipefail
docker run -it --rm $(DOCKER_PARAMS) -p 9001:9001 $(IMAGE_NAME) $(ARG_SEPARATOR) $(WITH_ARGS) docker network create --driver bridge vinyldns_net &> /dev/null || true
docker run -it --rm $(DOCKER_PARAMS) --network vinyldns_net -p 9001:9001 $(IMAGE_NAME) $(ARG_SEPARATOR) $(WITH_ARGS)
run-bg: run-bg:
@set -euo pipefail @set -euo pipefail
docker stop $(IMAGE_NAME) &> /dev/null || true docker stop $(IMAGE_NAME) &> /dev/null || true
docker rm $(IMAGE_NAME) &> /dev/null || true docker rm $(IMAGE_NAME) &> /dev/null || true
docker run -td --name $(IMAGE_NAME) --rm $(DOCKER_PARAMS) -p 9001:9001 $(IMAGE_NAME) -- /bin/bash docker network create --driver bridge vinyldns_net &> /dev/null || true
docker run -td --name $(IMAGE_NAME) --rm $(DOCKER_PARAMS) --network vinyldns_net -p 9001:9001 $(IMAGE_NAME) -- /bin/bash

View File

@ -39,6 +39,7 @@ crypto {
} }
http.port = 9001 http.port = 9001
http.port = ${?PORTAL_PORT}
data-stores = ["mysql"] data-stores = ["mysql"]
@ -58,3 +59,4 @@ mysql {
# You generate this yourself following https://www.playframework.com/documentation/2.7.x/ApplicationSecret # You generate this yourself following https://www.playframework.com/documentation/2.7.x/ApplicationSecret
play.http.secret.key = "rpkTGtoJvLIdIV?WU=0@yW^x:pcEGyAt`^p/P3G0fpbj9:uDnD@caSjCDqA0@tB=" play.http.secret.key = "rpkTGtoJvLIdIV?WU=0@yW^x:pcEGyAt`^p/P3G0fpbj9:uDnD@caSjCDqA0@tB="
play.http.secret.key = ${?PLAY_HTTP_SECRET_KEY}

View File

@ -8,7 +8,10 @@
##################################################################################################### #####################################################################################################
set -eo pipefail set -eo pipefail
DIR=$( cd "$(dirname "$0")" || exit ; pwd -P ) DIR=$(
cd "$(dirname "$0")" || exit
pwd -P
)
source "${DIR}/../utils/includes/terminal_colors.sh" source "${DIR}/../utils/includes/terminal_colors.sh"
function usage() { function usage() {
@ -18,10 +21,12 @@ function usage() {
echo -e "options:" echo -e "options:"
echo -e "\t-a, --api-only do not start up the VinylDNS Portal" echo -e "\t-a, --api-only do not start up the VinylDNS Portal"
echo -e "\t-b, --build force a rebuild of the Docker images with the local code" echo -e "\t-b, --build force a rebuild of the Docker images with the local code"
echo -e "\t-c, --clean stops all VinylDNS containers"
echo -e "\t-d, --deps-only only start up the dependencies, not the API or Portal"
echo -e "\t-r, --reset reset any the running containers" echo -e "\t-r, --reset reset any the running containers"
echo -e "\t-s, --service specify the service to run" echo -e "\t-s, --service specify the service to run"
echo -e "\t-t, --timeout the time to wait (in seconds) for the portal and API to start (default: 60)" echo -e "\t-t, --timeout the time to wait (in seconds) for the Portal and API to start (default: 60)"
echo -e "\t-u, --update remove the local quickstart images to force a re-pull from docker hub" echo -e "\t-u, --update remove the local quickstart images to force a re-pull from Docker Hub"
echo -e "\t-v, --version-tag specify Docker image tag version (default: latest)" echo -e "\t-v, --version-tag specify Docker image tag version (default: latest)"
echo echo
echo -e "\t-h, --help show this help" echo -e "\t-h, --help show this help"
@ -46,22 +51,31 @@ function wait_for_url() {
fi fi
done done
} }
function is_running() {
if (docker ps --format "{{.Image}}" | grep -q "$1"); then
return 0
fi
return 1
}
function wait_for_api() { function wait_for_api() {
URL="$VINYLDNS_API_URL" if is_running "vinyldns/api"; then
wait_for_url "VinylDNS API" URL="$VINYLDNS_API_URL"
wait_for_url "VinylDNS API"
fi
} }
function wait_for_portal() { function wait_for_portal() {
# check if portal was skipped if is_running "vinyldns/portal"; then
if [ "$SERVICE" != "api" ]; then
URL="$VINYLDNS_PORTAL_URL" URL="$VINYLDNS_PORTAL_URL"
wait_for_url "VinylDNS Portal" wait_for_url "VinylDNS Portal"
fi fi
} }
# Source customizable env files ('-a' causes all variables to be exported) # Source customizable env files ('-a' causes all variables to be exported)
set -a; source "${DIR}/.env"; set +a set -a
source "${DIR}/.env"
set +a
# Set defaults and parse args # Set defaults and parse args
export VINYLDNS_VERSION=latest export VINYLDNS_VERSION=latest
@ -71,6 +85,7 @@ SERVICE=""
BUILD="" BUILD=""
RESET_DOCKER=0 RESET_DOCKER=0
UPDATE=0 UPDATE=0
CLEAN=0
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
-t | --timeout) -t | --timeout)
@ -78,10 +93,18 @@ while [[ $# -gt 0 ]]; do
shift shift
shift shift
;; ;;
-d | --deps-only)
SERVICE="integration ldap"
shift
;;
-a | --api-only) -a | --api-only)
SERVICE="api" SERVICE="api"
shift shift
;; ;;
-c | --clean)
CLEAN=1
shift
;;
-s | --service) -s | --service)
SERVICE="$2" SERVICE="$2"
shift shift
@ -111,8 +134,12 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
if [[ $RESET_DOCKER -eq 1 ]]; then if [[ $RESET_DOCKER -eq 1 ]] || [[ $CLEAN -eq 1 ]]; then
"${DIR}/../utils/clean-vinyldns-containers.sh" "${DIR}/../utils/clean-vinyldns-containers.sh"
if [[ $CLEAN -eq 1 ]]; then
echo "${F_GREEN}Clean up completed!${F_RESET}"
exit 0
fi
fi fi
export VINYLDNS_IMAGE_VERSION=${VINYLDNS_VERSION} export VINYLDNS_IMAGE_VERSION=${VINYLDNS_VERSION}
@ -134,17 +161,22 @@ if [ -n "${BUILD}" ]; then
else else
echo "Starting VinylDNS (${VINYLDNS_IMAGE_VERSION}) the background..." echo "Starting VinylDNS (${VINYLDNS_IMAGE_VERSION}) the background..."
fi fi
docker-compose -f "${DOCKER_COMPOSE_CONFIG}" up ${BUILD} -d ${SERVICE} || (echo -e "${F_RED}Sorry, there was an error starting VinylDNS :-(\nTry resetting any existing containers with:\n\t${F_RESET}'$0 --reset'"; exit 1) docker-compose -f "${DOCKER_COMPOSE_CONFIG}" up ${BUILD} -d ${SERVICE} || (
echo -e "${F_RED}Sorry, there was an error starting VinylDNS :-(\nTry resetting any existing containers with:\n\t${F_RESET}'$0 --reset'"
exit 1
)
echo echo
wait_for_api wait_for_api
wait_for_portal wait_for_portal
echo echo
if [ "${SERVICE}" != "api" ]; then if is_running "vinyldns/portal"; then
echo "${F_GREEN}VinylDNS started. You can connect to the portal via ${F_RESET}${VINYLDNS_PORTAL_URL}" echo "${F_GREEN}VinylDNS started! You can connect to the portal via ${F_RESET}${VINYLDNS_PORTAL_URL}"
elif is_running "vinyldns/api"; then
echo "${F_GREEN}VinylDNS API started! You can connect to the API via ${F_RESET}${VINYLDNS_API_URL}"
else else
echo "${F_GREEN}VinylDNS API started. You can connect to the API via ${F_RESET}${VINYLDNS_API_URL}" echo "${F_GREEN}VinylDNS dependencies started!${F_RESET}"
fi fi
echo "${F_GREEN}To clean up the running containers:${F_RESET}" echo "${F_GREEN}To clean up the running containers:${F_RESET}"
echo " $0 --reset" echo " $0 --clean"