From 1af13768d5c173d5f938d722b4bce9ab59736d46 Mon Sep 17 00:00:00 2001
From: Aleaxnder Hinneburg <alexander.hinneburg@informatik.uni-halle.de>
Date: Fri, 7 Jun 2024 17:54:03 +0200
Subject: [PATCH] Docker Wrapper

---
 .gitlab-ci.yml | 31 +++++++++++++++++++++++++++++++
 Dockerfile     | 17 +++++++++++++++++
 2 files changed, 48 insertions(+)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 Dockerfile

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..f1b66fd
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,31 @@
+docker-build:
+  # Use the official docker image.
+  image: docker:stable
+  stage: build
+  services:
+    - name: 'docker:dind'
+      alias: mydocker
+      command: ['--tls=false']
+  variables:
+    DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
+    DOCKER_HOST: tcp://mydocker:2375/
+    DOCKER_TLS_CERTDIR: ""
+  before_script:
+    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
+  # All branches are tagged with $DOCKER_IMAGE_NAME (defaults to commit ref slug)
+  # Default branch is also tagged with `latest`
+  script:
+    - docker build -t "$DOCKER_IMAGE_NAME" . # --pull -t "$DOCKER_IMAGE_NAME" .
+    - docker push "$DOCKER_IMAGE_NAME"
+    - |
+      if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
+        docker tag "$DOCKER_IMAGE_NAME" "$CI_REGISTRY_IMAGE:latest"
+        docker push "$CI_REGISTRY_IMAGE:latest"
+      fi
+  # Run this job in a branch where a Dockerfile exists
+  rules:
+    - if: $CI_COMMIT_BRANCH
+      exists:
+        - Dockerfile
+
+
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..07cabfc
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,17 @@
+# derive from any base image you want
+FROM alpine:latest
+
+# copy PostgREST over
+COPY --from=postgrest/postgrest /bin/postgrest /bin
+
+# add your other stuff
+EXPOSE 3000
+
+# This is the user id that Docker will run our image under by default. Note
+# that we don't actually add the user to `/etc/passwd` or `/etc/shadow`. This
+# means that tools like whoami would not work properly, but we don't include
+# those in the image anyway. Not adding the user has the benefit that the image
+# can be run under any user you specify.
+USER 1000
+
+CMD [ "/bin/postgrest" ]
\ No newline at end of file
-- 
GitLab