diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..f1b66fd5e823a91cffa18d789ab23fb9a91543d1 --- /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 0000000000000000000000000000000000000000..07cabfc537e26c8134c00b6040dc300a67107498 --- /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