Skip to content

Commit

Permalink
docker fixes
Browse files Browse the repository at this point in the history
using bash for scripts
move ui base docker to 14
fixing zts local start up

Signed-off-by: Abhijeet V <[email protected]>
  • Loading branch information
abvaidya committed Jan 6, 2022
1 parent 6435ea2 commit 8e471cb
Show file tree
Hide file tree
Showing 40 changed files with 58 additions and 51 deletions.
18 changes: 9 additions & 9 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,42 @@ deploy-dev:
docker run --rm -t -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz-setup-env sh /athenz/docker/setup-scripts/self-signed-certificates.sh
# ZMS
docker run --rm -t -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz-setup-env sh /athenz/docker/setup-scripts/zms-auto-config.sh
sh "./deploy-scripts/zms-deploy.sh"
./deploy-scripts/zms-deploy.sh
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz-setup-env sh /athenz/docker/deploy-scripts/zms-debug.sh
# ZTS
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz-setup-env sh /athenz/docker/setup-scripts/zts-auto-config.sh
sh "./deploy-scripts/zts-deploy.sh"
./deploy-scripts/zts-deploy.sh
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz-setup-env sh /athenz/docker/deploy-scripts/zts-debug.sh

deploy-local:
# generate self-signed certificates
docker run --rm -t -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/setup-scripts/self-signed-certificates.sh
# ZMS
docker run --rm -t -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/setup-scripts/zms-auto-config.sh
sh "./deploy-scripts/zms-deploy-local.sh"
./deploy-scripts/zms-deploy-local.sh
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/deploy-scripts/zms-debug.sh
# ZTS
sh "./amazon-trust.sh"
./amazon-trust.sh
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/setup-scripts/zts-auto-config.sh
sh "./deploy-scripts/zts-deploy-local.sh"
./deploy-scripts/zts-deploy-local.sh
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/deploy-scripts/zts-debug.sh
# UI
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/setup-scripts/ui-auto-config.sh
sh "./deploy-scripts/ui-deploy-local.sh"
./deploy-scripts/ui-deploy-local.sh

prepare-ui-dev-env:
# generate self-signed certificates
docker run --rm -t -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/setup-scripts/self-signed-certificates.sh
# ZMS
docker run --rm -t -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/setup-scripts/zms-auto-config.sh
sh "./deploy-scripts/zms-deploy-local.sh"
./deploy-scripts/zms-deploy-local.sh
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/deploy-scripts/zms-debug.sh
# ZTS
sh "./amazon-trust.sh"
./amazon-trust.sh
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/setup-scripts/zts-auto-config.sh
# UI defaults
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz/athenz-setup-env sh /athenz/docker/setup-scripts/ui-auto-config.sh
sh "./prepare-local-ui-dev-env.sh"
./prepare-local-ui-dev-env.sh

verify:
docker run --rm -t --network="$(DOCKER_NETWORK)" -v "$(BASE_DIR):/athenz" --user "$(shell id -u):$(shell id -g)" athenz-setup-env sh /athenz/docker/deploy-scripts/zms-verify.sh
Expand Down
2 changes: 1 addition & 1 deletion docker/amazon-trust.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

if test -e /etc/pki/tls/certs/ca-bundle.crt; then
BASE_DIR=$(git rev-parse --show-toplevel)
Expand Down
2 changes: 1 addition & 1 deletion docker/deploy-scripts/acceptance-test-reset.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/deploy-scripts/acceptance-test.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion docker/deploy-scripts/ui-deploy-local.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/deploy-scripts/zms-debug.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/deploy-scripts/zms-deploy-local.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/deploy-scripts/zms-deploy.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/deploy-scripts/zms-verify.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/deploy-scripts/zts-debug.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
4 changes: 2 additions & 2 deletions docker/deploy-scripts/zts-deploy-local.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down Expand Up @@ -80,7 +80,7 @@ docker exec --user mysql:mysql \
"${ZTS_DB_HOST}" mysql \
--database=zts_store \
--user=root --password="${ZTS_DB_ROOT_PASS}" \
--execute="CREATE USER 'zts_admin'@'${ZTS_HOST}.${DOCKER_NETWORK}' IDENTIFIED BY '${ZTS_DB_ADMIN_PASS}'; GRANT ALL PRIVILEGES ON zts_store.* TO 'zts_admin'@'${ZTS_HOST}.${DOCKER_NETWORK}'; FLUSH PRIVILEGES;"
--execute="CREATE USER 'zts_admin'@'%' IDENTIFIED BY '${ZTS_DB_ADMIN_PASS}'; GRANT ALL PRIVILEGES ON zts_store.* TO 'zts_admin'@'%'; FLUSH PRIVILEGES;"
docker exec --user mysql:mysql \
"${ZTS_DB_HOST}" mysql \
--database=mysql \
Expand Down
2 changes: 1 addition & 1 deletion docker/deploy-scripts/zts-deploy.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/deploy-scripts/zts-verify.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/docs/cast/bootstrap-demo-welcome-script.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -u
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/env.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -u
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/local-nameserver.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

nameservers=$( grep -v '^#' < /etc/resolv.conf | grep nameserver | awk '{print $2}')
LOCAL_ENV_NS=""
Expand Down
2 changes: 1 addition & 1 deletion docker/prepare-local-ui-dev-env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

BASE_DIR=$(git rev-parse --show-toplevel)
cp ${BASE_DIR}/docker/ui/var/keys/*.pem ${BASE_DIR}/ui/keys
Expand Down
2 changes: 1 addition & 1 deletion docker/sample/CAs/create-self-signed-ca.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/sample/domain-admin/create-self-signed-user-cert.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/sample/env.dev.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -u
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/sample/ui/create-self-signed-certs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/sample/zms/create-self-signed-certs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/sample/zts/create-self-signed-certs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/setup-scripts/common/color-print.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -u
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/setup-scripts/sample-identity.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

# to setup-scripts directory
cd "$(dirname "$0")"
Expand Down
2 changes: 1 addition & 1 deletion docker/setup-scripts/self-signed-certificates.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/setup-scripts/ui-auto-config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/setup-scripts/zms-auto-config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion docker/setup-scripts/zts-auto-config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
7 changes: 4 additions & 3 deletions docker/ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12.16.2-alpine AS builder
FROM node:fermium-alpine AS builder

RUN set -eux && apk update && apk add --no-cache --update ca-certificates libstdc++ libgcc tini make git

Expand Down Expand Up @@ -26,7 +26,7 @@ RUN rm -rf scripts \
&& rm -rf pom.xml \
&& rm -rf README.md

FROM node:12.16.2-alpine
FROM node:fermium-alpine
# date -u +'%Y-%m-%dT%H:%M:%SZ'
ARG BUILD_DATE
# git rev-parse --short HEAD
Expand All @@ -43,9 +43,10 @@ LABEL org.label-schema.vcs-ref=$VCS_REF
ARG GID=1001
ARG UID=10001

RUN mkdir -p /var/lib/sia/tokens/msd-api-access && touch /var/lib/sia/tokens/msd-api-access/msd-api-access-token
# add athenz user
RUN addgroup -g ${GID} athenz && \
adduser -S -D -H -s /sbin/nologin -u ${UID} -G athenz athenz
adduser -S -D -H -s /sbin/nologin -u ${UID} -G athenz athenz && chown -R athenz:athenz /var/lib/sia/tokens/msd-api-access
USER athenz

WORKDIR /opt/athenz/ui
Expand Down
3 changes: 1 addition & 2 deletions docker/zms/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

ZMS_STOP_TIMEOUT=${ZMS_STOP_TIMEOUT:-30}
ZMS_CLASSPATH="${CLASSPATH}:${USER_CLASSPATH}"
Expand All @@ -12,7 +12,6 @@ JAVA_OPTS="${JAVA_OPTS} -Dathenz.zms.jdbc_password=${ZMS_DB_ADMIN_PASS}"
JAVA_OPTS="${JAVA_OPTS} -Dathenz.zms.jdbc_ro_password=${ZMS_RODB_ADMIN_PASS}"
JAVA_OPTS="${JAVA_OPTS} -Dathenz.ssl_key_store_password=${ZMS_KEYSTORE_PASS}"
JAVA_OPTS="${JAVA_OPTS} -Dathenz.ssl_trust_store_password=${ZMS_TRUSTSTORE_PASS}"
JAVA_OPTS="${JAVA_OPTS} -Djava.io.tmpdir=/tmp"

### !!! P.S. cannot quote JAVA_OPTS !!!
### reference: https://github.com/koalaman/shellcheck/wiki/SC2086
Expand Down
3 changes: 3 additions & 0 deletions docker/zts/conf/athenz.properties
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,6 @@ athenz.graceful_shutdown=true
# How long to wait for the Jetty server to shutdown, in milliseconds
# If the athenz.graceful_shutdown is not true, this setting is invalid.
athenz.graceful_shutdown_timeout=30000

# Need this to start root-less container
athenz.jetty_temp=/tmp
2 changes: 1 addition & 1 deletion docker/zts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

ZTS_STOP_TIMEOUT=${ZTS_STOP_TIMEOUT:-30}
ZTS_CLASSPATH="${CLASSPATH}:${USER_CLASSPATH}"
Expand Down
2 changes: 1 addition & 1 deletion docs/local_ui_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ In this guide, you will be able to start a local ZMS server and do local ui deve

## Prerequisites

Docker, Make toolchain, Node v12.14.0, nodemon v2.0.3
Docker, Make toolchain, Node v14.x, nodemon v2.x

## Steps

Expand Down
2 changes: 1 addition & 1 deletion servers/zms/scripts/setup_dev_zms.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

# Determine our run-time directory

Expand Down
2 changes: 1 addition & 1 deletion servers/zts/scripts/setup_dev_zts.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

# Determine our run-time directory

Expand Down
2 changes: 1 addition & 1 deletion start-local-athenz.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion stop-local-athenz.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail
Expand Down
6 changes: 5 additions & 1 deletion ui/scripts/setup_dev_ui.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

# Determine our run-time directory

Expand Down Expand Up @@ -69,4 +69,8 @@ elif [ "$HOST_PLATFORM" == 'darwin' ] ; then
cat /dev/urandom | env LC_CTYPE=C tr -dc a-zA-Z0-9 | head -c 16 > "$ROOT"/keys/cookie-session
fi

echo "Creating a dummy token file"
sudo mkdir -p /var/lib/sia/tokens/msd-api-access/ && sudo chown -R "$(id -u)":"$(id -g)" /var/lib/sia/tokens/msd-api-access
touch /var/lib/sia/tokens/msd-api-access/msd-api-access-token

echo "Athenz UI Dev Environment setup complete"

0 comments on commit 8e471cb

Please sign in to comment.