Nixify CircleCI setup (#1535)
* package ghr * add nix-based release scripts * refactor CI based on nix tests and release scripts * update stack version in circleci * update makefile * remove docker directory * add Docker Hub description * add README on docker
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
{ buildEnv
|
||||
, curl
|
||||
, envsubst
|
||||
, ghr
|
||||
, jq
|
||||
, postgrest
|
||||
, docker
|
||||
, runCommand
|
||||
, writeShellScriptBin
|
||||
}:
|
||||
let
|
||||
# Version from the postgrest.cabal file (gotten with callCabal2nix).
|
||||
version = postgrest.version;
|
||||
|
||||
# Set of files that will be published in the GitHub release.
|
||||
releaseFiles =
|
||||
runCommand "postgrest-release-files"
|
||||
{ inherit postgrest version; }
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
mkdir -p $out
|
||||
|
||||
tar cvJf "$out"/postgrest-v"$version"-linux-x64-static.tar.xz \
|
||||
-C "$postgrest"/bin postgrest
|
||||
'';
|
||||
|
||||
# Script for publishing a new release on GitHub.
|
||||
github =
|
||||
writeShellScriptBin "postgrest-release-github"
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
changes="$(sed -n "1,/${version}/d;/## \[/q;p" ${../../CHANGELOG.md})"
|
||||
|
||||
${ghr}/bin/ghr \
|
||||
-t "$GITHUB_TOKEN" \
|
||||
-u "$GITHUB_USERNAME" \
|
||||
-r "$GITHUB_REPONAME" \
|
||||
-b "$changes" \
|
||||
--replace v${version} \
|
||||
${releaseFiles}
|
||||
'';
|
||||
|
||||
# Script for publishing a new release on Docker Hub.
|
||||
dockerHub =
|
||||
writeShellScriptBin "postgrest-release-dockerhub"
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
docker load -i ${docker.image}
|
||||
|
||||
docker tag postgrest:latest "$DOCKER_REPO"/postgrest:latest
|
||||
docker tag postgrest:latest "$DOCKER_REPO"/postgrest:v${version}
|
||||
|
||||
docker push "$DOCKER_REPO"/postgrest:latest
|
||||
docker push "$DOCKER_REPO"/postgrest:v${version}
|
||||
'';
|
||||
|
||||
# Script for updating the repository description on Docker Hub.
|
||||
dockerHubDescription =
|
||||
let
|
||||
description =
|
||||
./docker-hub-description.md;
|
||||
|
||||
fullDescription =
|
||||
./docker-hub-full-description.md;
|
||||
in
|
||||
writeShellScriptBin "postgrest-release-dockerhubdescription"
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
# Login to Docker Hub and get a token.
|
||||
token="$(
|
||||
${curl}/bin/curl -sH "Content-Type: application/json" \
|
||||
--data-urlencode "username=$DOCKER_USERNAME" \
|
||||
--data-urlencode "password=$DOCKER_PASSWORD" \
|
||||
"https://hub.docker.com/v2/users/login/" \
|
||||
| ${jq}/bin/jq -r .token
|
||||
)"
|
||||
|
||||
# Plug the default config file into the full description.
|
||||
export DEFAULT_CONFIG="$(cat ${docker.config})"
|
||||
fullDescription="$(${envsubst}/bin/envsubst < ${fullDescription})"
|
||||
|
||||
# Patch the full description.
|
||||
responseCode="$(
|
||||
${curl}/bin/curl -s --write-out %{response_code} --output /dev/null \
|
||||
-H "Authorization: JWT $token" -X PATCH \
|
||||
--data-urlencode description@${description} \
|
||||
--data-urlencode "full_description=$fullDescription" \
|
||||
"https://hub.docker.com/v2/repositories/$DOCKER_REPO/postgrest/"
|
||||
)"
|
||||
|
||||
[ "$responseCode" -eq 200 ]
|
||||
'';
|
||||
in
|
||||
buildEnv {
|
||||
name = "postgrest-release";
|
||||
paths = [ github dockerHub dockerHubDescription ];
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
REST API for any Postgres database
|
||||
@@ -0,0 +1,33 @@
|
||||
# PostgREST
|
||||
|
||||
[](https://gitter.im/begriffs/postgrest)
|
||||
[](https://www.patreon.com/postgrest)
|
||||
[](https://www.paypal.me/postgrest)
|
||||
[](http://postgrest.org)
|
||||
[](https://circleci.com/gh/PostgREST/postgrest/tree/master)
|
||||
|
||||
PostgREST serves a fully RESTful API from any existing PostgreSQL database. It
|
||||
provides a cleaner, more standards-compliant, faster API than you are likely to
|
||||
write from scratch.
|
||||
|
||||
# Usage
|
||||
|
||||
To learn how to use this container, see the [PostgREST Docker
|
||||
documentation](https://postgrest.com/en/stable/install.html#docker).
|
||||
|
||||
You can configure the PostgREST image by setting the enviroment variables used
|
||||
in the default `/etc/postgrest.conf` file or overriding that file. This is the
|
||||
default configuration file:
|
||||
|
||||
```
|
||||
$DEFAULT_CONFIG
|
||||
```
|
||||
|
||||
# How this image is built
|
||||
|
||||
The image is built from scratch using
|
||||
[Nix](https://nixos.org/nixpkgs/manual/#sec-pkgs-dockerTools) instead of a
|
||||
`Dockerfile`, which yields a higly secure and optimized image. This is also why
|
||||
no commands are listed in the image history. See the [PostgREST
|
||||
respository](https://github.com/PostgREST/postgrest/tree/master/nix/docker) for
|
||||
details on the build process and how to inspect the image.
|
||||
Reference in New Issue
Block a user