Skip to content
Snippets Groups Projects
Commit 55eb8dfe authored by Eric Frias's avatar Eric Frias
Browse files

Create docker image for postgrest url rewriter

parent 31e105dd
No related branches found
No related tags found
2 merge requests!83Merge develop to master for release,!47Create docker image for postgrest url rewriter
Pipeline #108402 passed
FROM openresty/openresty:alpine AS without_tag
COPY docker/reputation_tracker_nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
COPY rewrite_rules.conf /usr/local/openresty/nginx/conf/rewrite_rules.conf
ARG BUILD_TIME
ARG GIT_COMMIT_SHA
ARG GIT_CURRENT_BRANCH
ARG GIT_LAST_LOG_MESSAGE
ARG GIT_LAST_COMMITTER
ARG GIT_LAST_COMMIT_DATE
LABEL org.opencontainers.image.created="$BUILD_TIME"
LABEL org.opencontainers.image.url="https://hive.io/"
LABEL org.opencontainers.image.documentation="https://gitlab.syncad.com/hive/reputation_tracker"
LABEL org.opencontainers.image.source="https://gitlab.syncad.com/hive/reputation_tracker"
#LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.revision="$GIT_COMMIT_SHA"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.ref.name="Reputation Tracker"
LABEL org.opencontainers.image.title="Reputation Tracker PostgREST URL Rewriter Image"
LABEL org.opencontainers.image.description="Rewrites REST calls to provide more natural REST URLs than PostgREST alone allows"
LABEL io.hive.image.branch="$GIT_CURRENT_BRANCH"
LABEL io.hive.image.commit.log_message="$GIT_LAST_LOG_MESSAGE"
LABEL io.hive.image.commit.author="$GIT_LAST_COMMITTER"
LABEL io.hive.image.commit.date="$GIT_LAST_COMMIT_DATE"
FROM without_tag AS with_tag
ARG GIT_COMMIT_TAG
LABEL org.opencontainers.image.version="${GIT_COMMIT_TAG}"
#
# Homepage and endpoints of the API "HAF Block Explorer".
#
worker_processes 5;
error_log /dev/stdout info;
worker_rlimit_nofile 8192;
events {
worker_connections 4096;
}
http {
access_log /dev/stdout;
server {
listen 0.0.0.0:80 default_server;
server_name _;
location / {
include rewrite_rules.conf;
rewrite_log on;
proxy_pass http://reputation-tracker-postgrest:3000; # my PostREST is here!
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#default_type;
proxy_hide_header Content-Location;
proxy_set_header Connection "";
proxy_http_version 1.1;
}
}
}
...@@ -29,7 +29,7 @@ while [ $# -gt 0 ]; do ...@@ -29,7 +29,7 @@ while [ $# -gt 0 ]; do
--tag=*) --tag=*)
arg="${1#*=}" arg="${1#*=}"
BASE_TAG="$arg" BASE_TAG="$arg"
;; ;;
--progress=*) --progress=*)
arg="${1#*=}" arg="${1#*=}"
PROGRESS_DISPLAY="$arg" PROGRESS_DISPLAY="$arg"
...@@ -89,7 +89,7 @@ export GIT_COMMIT_SHA ...@@ -89,7 +89,7 @@ export GIT_COMMIT_SHA
GIT_CURRENT_BRANCH="$(git branch --show-current || true)" GIT_CURRENT_BRANCH="$(git branch --show-current || true)"
if [ -z "$GIT_CURRENT_BRANCH" ]; then if [ -z "$GIT_CURRENT_BRANCH" ]; then
GIT_CURRENT_BRANCH="$(git describe --abbrev=0 --all | sed 's/^.*\///' || true)" GIT_CURRENT_BRANCH="$(git describe --abbrev=0 --all --exclude 'pipelines/*' | sed 's/^.*\///' || true)"
if [ -z "$GIT_CURRENT_BRANCH" ]; then if [ -z "$GIT_CURRENT_BRANCH" ]; then
GIT_CURRENT_BRANCH="[unknown]" GIT_CURRENT_BRANCH="[unknown]"
fi fi
...@@ -116,4 +116,25 @@ export GIT_LAST_COMMIT_DATE ...@@ -116,4 +116,25 @@ export GIT_LAST_COMMIT_DATE
docker buildx bake --provenance=false --progress="$PROGRESS_DISPLAY" "$TARGET" docker buildx bake --provenance=false --progress="$PROGRESS_DISPLAY" "$TARGET"
popd REWRITER_TARGET=without_tag
\ No newline at end of file if [ -n "$BASE_TAG" ]; then
REWRITER_TARGET=with_tag
TAG_BUILD_ARGS="--build-arg GIT_COMMIT_TAG=$BASE_TAG"
fi
# shellcheck disable=SC2086
docker buildx build \
--build-arg BUILD_TIME="$BUILD_TIME" \
--build-arg GIT_COMMIT_SHA="$GIT_COMMIT_SHA" \
--build-arg GIT_CURRENT_BRANCH="$GIT_CURRENT_BRANCH" \
--build-arg GIT_LAST_LOG_MESSAGE="$GIT_LAST_LOG_MESSAGE" \
--build-arg GIT_LAST_COMMITTER="$GIT_LAST_COMMITTER" \
--build-arg GIT_LAST_COMMIT_DATE="$GIT_LAST_COMMIT_DATE" \
--target=$REWRITER_TARGET \
$TAG_BUILD_ARGS \
--tag "$CI_REGISTRY_IMAGE/postgrest-rewriter:$BASE_TAG" \
--load \
--file Dockerfile.rewriter .
docker push "$CI_REGISTRY_IMAGE/postgrest-rewriter:$BASE_TAG"
popd
...@@ -45,9 +45,9 @@ _TST_REGISTRY=${REGISTRY:?"Missing arg #3 - container registry URL"} ...@@ -45,9 +45,9 @@ _TST_REGISTRY=${REGISTRY:?"Missing arg #3 - container registry URL"}
pushd "$SRCROOTDIR" pushd "$SRCROOTDIR"
# On CI build the image using the registry-stored BuildKit cache # On CI build the image using the registry-stored BuildKit cache
# and push it to registry immediately. # and push it to registry immediately.
# Locally, build it using local BuildKit cache and load it to the # Locally, build it using local BuildKit cache and load it to the
# local image store. # local image store.
if [[ -n ${CI:-} ]]; then if [[ -n ${CI:-} ]]; then
TARGET="full-ci" TARGET="full-ci"
...@@ -65,4 +65,4 @@ fi ...@@ -65,4 +65,4 @@ fi
docker tag "$REGISTRY:$BUILD_IMAGE_TAG" "$REGISTRY/instance:$BUILD_IMAGE_TAG" docker tag "$REGISTRY:$BUILD_IMAGE_TAG" "$REGISTRY/instance:$BUILD_IMAGE_TAG"
docker tag "$REGISTRY:$BUILD_IMAGE_TAG" "$REGISTRY/minimal-instance:$BUILD_IMAGE_TAG" docker tag "$REGISTRY:$BUILD_IMAGE_TAG" "$REGISTRY/minimal-instance:$BUILD_IMAGE_TAG"
popd popd
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment