diff --git a/.gitignore b/.gitignore index b567c20..d7057b6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ vars/*.tfvars prod-user-pool.json *-secret-vars.yml /configure/certificates/** -/configure/dummy.yml \ No newline at end of file +/configure/dummy.yml +/reportingSystem/superset/superset.env diff --git a/reportingSystem/superset/Dockerfile b/reportingSystem/superset/Dockerfile new file mode 100644 index 0000000..cb6589d --- /dev/null +++ b/reportingSystem/superset/Dockerfile @@ -0,0 +1,27 @@ +ARG TAG=latest + +FROM apache/superset:${TAG} + + +#Copy avni logo and favicon +ADD --chown=superset https://raw.githubusercontent.com/avniproject/avni-website/master/src/img/avni-logo-color.png /app/superset/static/assets/images/avni.png +ADD --chown=superset https://github.com/avniproject/avni-webapp/raw/master/public/favicon.ico /app/superset/static/assets/images/avni-favicon.ico + +# Copy the configuration file, set the environment variable, +COPY --chown=superset ./assets/superset_config.py /app/ + +#Environment variable +ENV SUPERSET_SECRET_KEY="" +ENV SUPERSET_DB_USER=postgres +ENV SUPERSET_DB_PASSWORD=password +ENV SUPERSET_DB_URL=host.docker.internal +ENV SUPERSET_DB_PORT=5432 +ENV SUPERSET_CONFIG_PATH=/app/superset_config.py + + +# Expose the port +EXPOSE 8088 + + +# Run superset +ENTRYPOINT ["superset", "run", "-h", "0.0.0.0", "-p", "8088", "--with-threads", "--reload", "--debugger"] \ No newline at end of file diff --git a/reportingSystem/superset/Makefile b/reportingSystem/superset/Makefile new file mode 100644 index 0000000..b88b001 --- /dev/null +++ b/reportingSystem/superset/Makefile @@ -0,0 +1,41 @@ +IMAGE := vedfordocker/superset +TAG ?= 4.0.1 + +build-image: + @echo "building image $(IMAGE):$(TAG)" + docker image build --build-arg TAG=$(TAG) -t $(IMAGE):$(TAG) . + +re-build-image:delete-image + @echo "building image $(IMAGE):$(TAG)" + docker image build --build-arg version=$(TAG) -t $(IMAGE):$(TAG) . + +delete-image: + @if docker image inspect $(IMAGE):$(TAG) > /dev/null 2>&1; then \ + echo "Image $(IMAGE):$(TAG) found. Deleting..."; \ + docker image rm -f $(IMAGE):$(TAG); \ + else \ + echo "Image $(IMAGE):$(TAG) not found."; \ + fi + +push-image: + docker push $(IMAGE):$(TAG) + + +inspect-image: + docker image inspect $(IMAGE):$(TAG) + +run-container: + docker run -d -p 8088:8088 \ + --name superset_$(TAG) \ + --env-file superset.env \ + $(IMAGE):$(TAG) + @$(MAKE) get-container-logs + +remove-container: + docker container rm -f superset_$(TAG) + +get-container-logs: + docker logs -f superset_$(TAG) + +execute-container: + docker container exec -it superset_$(TAG) bash diff --git a/reportingSystem/superset/assets/superset_config.py b/reportingSystem/superset/assets/superset_config.py index dd15b10..2342b0b 100644 --- a/reportingSystem/superset/assets/superset_config.py +++ b/reportingSystem/superset/assets/superset_config.py @@ -1,6 +1,7 @@ -SECRET_KEY = # secret key add +import os -PREVIOUS_SECRET_KEY = # add details +# secret key add +SECRET_KEY = os.getenv('SUPERSET_SECRET_KEY') CONTENT_SECURITY_POLICY_WARNING = False @@ -12,7 +13,12 @@ "ALLOW_FULL_CSV_EXPORT": True } -SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://:@:5432/supersetdb' +DB_USER = os.getenv('SUPERSET_DB_USER') +DB_PASSWORD = os.getenv('SUPERSET_DB_PASSWORD') +DB_URL = os.getenv('SUPERSET_DB_URL') +DB_PORT = os.getenv('SUPERSET_DB_PORT') + +SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://"+DB_USER+":"+DB_PASSWORD+"@"+DB_URL+":"+DB_PORT+"/supersetdb" APP_ICON = "/static/assets/images/avni.png"