Skip to content
Snippets Groups Projects
Commit 81a6eb7b authored by Michal Zander's avatar Michal Zander Committed by Michał Kudela
Browse files

Add postgrest setup

parent a9b0df17
No related branches found
No related tags found
2 merge requests!827Merge develop changes to master,!717Rewrite python function to sql ( condenser_api )
......@@ -2,6 +2,10 @@
# Base docker file having defined environment for build and run of a Hivemind instance.
# Use scripts/ci/build_ci_base_image.sh to build a new version of the CI base image. It must be properly tagged and pushed to the container registry.
ARG POSTGREST_VERSION=v12.0.2
FROM postgrest/postgrest:${POSTGREST_VERSION} AS pure_postgrest
FROM --platform=$BUILDPLATFORM python:3.8-slim as runtime
ARG TARGETPLATFORM
......@@ -96,12 +100,19 @@ ARG HTTP_PORT=8080
ENV HTTP_PORT=${HTTP_PORT}
# Lets use by default host address from default docker bridge network
ARG POSTGRES_URL="postgresql://hivemind@172.17.0.1/haf_block_log"
ARG POSTGRES_URL="postgresql://hivemind@haf-instance:5432/haf_block_log"
ENV POSTGRES_URL=${POSTGRES_URL}
ARG POSTGRES_ADMIN_URL="postgresql://haf_admin@172.17.0.1:5432/haf_block_log"
ENV POSTGRES_ADMIN_URL=${POSTGRES_ADMIN_URL}
ARG USE_POSTGREST=1
ENV USE_POSTGREST=${USE_POSTGREST}
ENV PGRST_DB_SCHEMA="hivemind_endpoints"
ENV PGRST_DB_ANON_ROLE="hivemind"
ENV PGRST_DB_ROOT_SPEC="home"
ENV LANG=en_US.UTF-8
USER hivemind
......@@ -109,6 +120,7 @@ WORKDIR /home/hivemind
SHELL ["/bin/bash", "-c"]
COPY --chmod=755 --from=pure_postgrest /bin/postgrest /usr/local/bin
COPY --from=builder --chown=hivemind:hivemind /home/hivemind/app/dist /home/hivemind/dist
COPY --from=builder --chown=hivemind:hivemind /home/hivemind/.hivemind-venv /home/hivemind/.hivemind-venv
COPY --from=builder --chown=hivemind:hivemind /home/hivemind/app/docker/docker_entrypoint.sh .
......
db-uri = "postgres://haf_admin@/haf_block_log"
db-schema = "hivemind_endpoints"
db-anon-role = "hivemind"
db-pool = 20
db-pool-acquisition-timeout = 10
server-port = 3000
admin-server-port = 3001
\ No newline at end of file
#!/bin/bash
set -e
set -o pipefail
POSTGRES_HOST="localhost"
POSTGRES_PORT=5432
POSTGRES_USER="hivemind"
WEBSERVER_PORT=8080
ADMIN_PORT=3001
while [ $# -gt 0 ]; do
case "$1" in
--host=*)
POSTGRES_HOST="${1#*=}"
;;
--port=*)
POSTGRES_PORT="${1#*=}"
;;
--user=*)
POSTGRES_USER="${1#*=}"
;;
--webserver_port|--webserver-port=*)
WEBSERVER_PORT="${1#*=}"
;;
--admin_port|--admin-port=*)
ADMIN_PORT="${1#*=}"
;;
--postgres-url=*)
POSTGRES_URL="${1#*=}"
;;
-*)
echo "ERROR: '$1' is not a valid option"
echo
exit 1
;;
*)
echo "ERROR: '$1' is not a valid argument"
echo
exit 2
;;
esac
shift
done
POSTGRES_ACCESS=${POSTGRES_URL:-"postgresql://$POSTGRES_USER@$POSTGRES_HOST:$POSTGRES_PORT/haf_block_log"}
start_webserver() {
export PGRST_DB_URI=$POSTGRES_ACCESS
export PGRST_SERVER_PORT=$WEBSERVER_PORT
export PGRST_ADMIN_SERVER_PORT=$ADMIN_PORT
export PGRST_DB_ROOT_SPEC="home"
postgrest postgrest.conf
}
start_webserver &
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment