Commit 225caba9 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Merge branch 'OCF110-fix-certificates-local-deployment-with-different-hostname' into 'staging'

Resolve "Fix certificates local deployment with different hostname"

Closes #110

See merge request !102
parents 3dc1053d cfb7c695
Loading
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
# Directories variables setup (no modification needed)
export SERVICES_DIR=$(dirname "$(readlink -f "$0")")
export CAPIF_BASE_DIR=$(dirname "$SERVICES_DIR")
# Path to the register config.yaml file
REGISTER_CONFIG_FILE="$SERVICES_DIR/register/config.yaml"

help() {
  echo "Usage: $1 <options>"
@@ -81,6 +83,15 @@ for FILE in "${FILES[@]}"; do
    fi
done

# Check if the backup config.yaml file exists before restoring
if [ -f "$REGISTER_CONFIG_FILE.bak" ]; then
  git update-index --no-assume-unchanged "$REGISTER_CONFIG_FILE.bak"
  mv "$REGISTER_CONFIG_FILE.bak" "$REGISTER_CONFIG_FILE"
  git update-index --no-assume-unchanged "$REGISTER_CONFIG_FILE"
else
  echo "Backup config file not found, skipping restore."
fi

docker network rm capif-network

docker volume prune --all --force
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ services:
      - VAULT_PORT=8200
      - LOG_LEVEL=${LOG_LEVEL}
      - TIMEOUT=10
      - CAPIF_HOSTNAME=${CAPIF_HOSTNAME}
    extra_hosts:
      - host.docker.internal:host-gateway
      - vault:host-gateway
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ services:
    environment:
      - VAULT_DEV_ROOT_TOKEN_ID=dev-only-token
      - VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200
      - CAPIF_HOSTNAME=${CAPIF_HOSTNAME}
    volumes:
      - ./vault/data:/vault/data
      - ./vault/config:/vault/config
+0 −2
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN pip3 install --no-cache-dir -r requirements.txt
RUN apt-get update && apt-get install -y --no-install-recommends openssl curl redis

#ENV CAPIF_PRIV_KEY = $CAPIF_PRIV_KEY

COPY . /usr/src/app

EXPOSE 8080
+23 −1
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
# Directories variables setup (no modification needed)
export SERVICES_DIR=$(dirname "$(readlink -f "$0")")
export CAPIF_BASE_DIR=$(dirname "$SERVICES_DIR")
# Path to the register config.yaml file
REGISTER_CONFIG_FILE="$SERVICES_DIR/register/config.yaml"

help() {
  echo "Usage: $1 <options>"
@@ -40,6 +42,13 @@ else
  exit 1
fi

# Check if yq is installed
if ! command -v yq &> /dev/null
then
    echo "yq is not installed. Please install it first."
    exit 1
fi

# Read params
while getopts ":c:l:mshr" opt; do
  case $opt in
@@ -74,6 +83,7 @@ done

echo Nginx hostname will be $HOSTNAME, deploy $DEPLOY, monitoring $MONITORING_STATE

# Deploy Monitoring stack
if [ "$MONITORING_STATE" == "true" ] ; then
    echo '***Monitoring set as true***'
    echo '***Creating Monitoring stack***'
@@ -90,7 +100,8 @@ fi

docker network create capif-network

docker compose -f "$SERVICES_DIR/docker-compose-vault.yml" up --detach --build $CACHED_INFO
# Deploy Vault service
CAPIF_HOSTNAME=$HOSTNAME docker compose -f "$SERVICES_DIR/docker-compose-vault.yml" up --detach --build $CACHED_INFO

status=$?
if [ $status -eq 0 ]; then
@@ -100,6 +111,7 @@ else
    exit $status
fi

# Deploy Capif services
CAPIF_HOSTNAME=$HOSTNAME MONITORING=$MONITORING_STATE LOG_LEVEL=$LOG_LEVEL docker compose -f "$SERVICES_DIR/docker-compose-capif.yml" up --detach --build $CACHED_INFO

status=$?
@@ -110,6 +122,15 @@ else
    exit $status
fi

# Backup Original config.yaml file
cp $REGISTER_CONFIG_FILE $REGISTER_CONFIG_FILE.bak
# Mark the file as assume-unchanged
git update-index --assume-unchanged "$REGISTER_CONFIG_FILE"

# Edit Register Service URL within ccf in the config.yaml file
yq eval ".ccf.url = \"$HOSTNAME\"" -i "$REGISTER_CONFIG_FILE"

# Deploy Register service
CAPIF_PRIV_KEY_BASE_64=$(echo "$(cat nginx/certs/server.key)")
CAPIF_PRIV_KEY=$CAPIF_PRIV_KEY_BASE_64 LOG_LEVEL=$LOG_LEVEL docker compose -f "$SERVICES_DIR/docker-compose-register.yml" up --detach --build $CACHED_INFO

@@ -121,6 +142,7 @@ else
    exit $status
fi

# Deploy Robot Mock Server
if [ "$ROBOT_MOCK_SERVER" == "true" ] ; then
    echo '***Robot Mock Server set as true***'
    echo '***Creating Robot Mock Server stack***'
Loading