Commit f540ba3e authored by Daniel Scholl's avatar Daniel Scholl
Browse files

Containerized the Schema Load Process so that it could be run without a pipeline

parent 535c2fbd
Pipeline #26672 failed with stages
in 2 minutes and 11 seconds
FROM alpine:3.13
ARG DATA_PARTITION=opendes
ENV BUILD_PACKAGES \
python3 \
gcc \
py-cryptography
ENV PYTHONUNBUFFERED=1 \
PATH="/home/osdu/.local/bin:${PATH}" \
DATA_PARTITION=${DATA_PARTITION} \
AZURE_DEPLOYMENTS_SUBDIR=. \
AZURE_DEPLOYMENTS_SCRIPTS_SUBDIR=.
USER root
RUN set -x \
echo "**** install Python ****" && \
apk update && \
apk add --no-cache ${BUILD_PACKAGES} && \
if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python ; fi && \
\
echo "**** install pip ****" && \
python3 -m ensurepip && \
rm -r /usr/lib/python*/ensurepip && \
pip3 install --no-cache --upgrade pip setuptools wheel && \
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi &&\
rm -rf /var/cache/apk/*
# Create osdu user
RUN addgroup -S osdu && adduser -S osdu -G osdu
WORKDIR /home/osdu
# Install Requirements
ADD scripts/azure/requirements.txt ./requirements.txt
RUN pip install -r requirements.txt
# Add Scripts
ADD scripts/*.py scripts/
ADD scripts/azure/*.py scripts/
ADD scripts/azure/bootstrap.sh scripts/
RUN chmod +x scripts/bootstrap.sh
# Add Schemas
ADD shared-schemas shared-schemas
USER osdu
WORKDIR /home/osdu/scripts
ENTRYPOINT ["/home/osdu/scripts/bootstrap.sh"]
## Service Schema Loading
This is a manual process to load shared schemas.
```bash
# Setup Variables
UNIQUE="<your_osdu_unique>" # ie: demo
AZURE_DNS_NAME="<your_osdu_fqdn>" # ie: osdu-$UNIQUE.contoso.com
DATA_PARTITION="<your_partition>" # ie:opendes
# This logs your local Azure CLI in using the configured service principal.
az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET --tenant $ARM_TENANT_ID
GROUP=$(az group list --query "[?contains(name, 'cr${UNIQUE}')].name" -otsv)
ENV_VAULT=$(az keyvault list --resource-group $GROUP --query [].name -otsv)
cat > .env << EOF
DATA_PARTITION=$DATA_PARTITION
AZURE_TENANT_ID=$ARM_TENANT_ID
AZURE_DNS_NAME=$AZURE_DNS_NAME
AZURE_AD_APP_RESOURCE_ID=$(az keyvault secret show --id https://${ENV_VAULT}.vault.azure.net/secrets/aad-client-id --query value -otsv)
AZURE_CLIENT_ID=$(az keyvault secret show --id https://${ENV_VAULT}.vault.azure.net/secrets/app-dev-sp-username --query value -otsv)
AZURE_CLIENT_SECRET=$(az keyvault secret show --id https://${ENV_VAULT}.vault.azure.net/secrets/app-dev-sp-password --query value -otsv)
EOF
(cd ../.. && docker build -f scripts/azure/Dockerfile -t schema-service-load:latest .)
docker run -it --env-file .env schema-service-load:latest
```
#!/bin/sh
set -e
export AZURE_SCHEMA_URL=https://$AZURE_DNS_NAME/api/schema-service/v1/schema
BEARER_TOKEN=`python $AZURE_DEPLOYMENTS_SUBDIR/Token.py`
export BEARER_TOKEN=$BEARER_TOKEN
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment