summaryrefslogtreecommitdiff
path: root/quickstart.sh
blob: 950475b341fb2e89b94684e062cd34659b6c9b2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh

source env-vars.sh

# Create a directory to store the certificates in.
if [ ! -d ${DOCKER_JWT_PUBKEY_PATH} ]; then
    mkdir ${DOCKER_JWT_PUBKEY_PATH}
fi

# And for the htpasswd file.
if [ ! -d ${DOCKER_JWT_HTPASSWD_PATH} ]; then
    mkdir ${DOCKER_JWT_HTPASSWD_PATH}
fi


# Generate new certificates to use for JWT.
if [ ! -f ${DOCKER_JWT_PUBKEY_PATH}/private.pem ] && [ ! -f ${DOCKER_JWT_PUBKEY_PATH}/public.pem ]; then
    openssl ecparam -genkey -name prime256v1 -noout -out ${DOCKER_JWT_PUBKEY_PATH}/private.pem
    chmod 644 ${DOCKER_JWT_PUBKEY_PATH}/private.pem
    openssl ec -in ${DOCKER_JWT_PUBKEY_PATH}/private.pem -pubout -out ${DOCKER_JWT_PUBKEY_PATH}/public.pem
fi

# Generate a default htpasswd file with a user "usr:pwd".
if [ ! -f ${DOCKER_JWT_HTPASSWD_PATH}/.htpasswd ]; then
    htpasswd -b -c ${DOCKER_JWT_HTPASSWD_PATH}/.htpasswd usr pwd
    htpasswd -b ${DOCKER_JWT_HTPASSWD_PATH}/.htpasswd user1 pwd
    htpasswd -b ${DOCKER_JWT_HTPASSWD_PATH}/.htpasswd user2 pwd
    htpasswd -b ${DOCKER_JWT_HTPASSWD_PATH}/.htpasswd user3 pwd
    htpasswd -b ${DOCKER_JWT_HTPASSWD_PATH}/.htpasswd user4 pwd
fi

if [ ! -f ${DOCKER_JWT_HTPASSWD_PATH}/userdb.yaml ]; then
    cp auth-server-poc/userdb.yaml ${DOCKER_JWT_HTPASSWD_PATH}/userdb.yaml
fi

# Launch the containers.
docker-compose -f docker/docker-compose-dev.yaml up -d
docker-compose -f auth-server-poc/docker-compose.yml up -d