Skip to content

Commit b934224

Browse files
authored
Merge pull request #2076 from dolthub/zachmu/docker-push
push to docker hub
2 parents e24c41e + fe10026 commit b934224

4 files changed

Lines changed: 205 additions & 1 deletion

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Push Docker Image to DockerHub
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'SemVer format release tag, i.e. 0.24.5'
8+
required: true
9+
repository_dispatch:
10+
types: [ push-docker-image ]
11+
12+
jobs:
13+
get-release-id:
14+
name: Get Doltgres Release Id
15+
runs-on: ubuntu-22.04
16+
outputs:
17+
release_id: ${{ steps.get_release.outputs.release_id }}
18+
steps:
19+
- name: Get Release
20+
id: get_release
21+
run: |
22+
release_id="$RELEASE_ID"
23+
if [ "$EVENT_TYPE" == "workflow_dispatch" ]; then
24+
release_id=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/dolthub/doltgresql/releases/tags/v${{ github.event.inputs.version }} | jq '.id')
25+
fi
26+
echo "release_id=$release_id" >> $GITHUB_OUTPUT
27+
env:
28+
EVENT_TYPE: ${{ github.event_name }}
29+
RELEASE_ID: ${{ github.event.client_payload.release_id }}
30+
31+
docker-image-push:
32+
name: Push Docker Image
33+
needs: get-release-id
34+
runs-on: ubuntu-22.04
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
- name: Login to Docker Hub
39+
uses: docker/login-action@v3
40+
with:
41+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
42+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
43+
- name: Set up QEMU
44+
uses: docker/setup-qemu-action@v3
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v3
47+
with:
48+
platforms: linux/amd64,linux/arm64
49+
- name: Build and push doltgres image
50+
uses: docker/build-push-action@v5
51+
with:
52+
platforms: linux/amd64,linux/arm64
53+
context: .
54+
file: ./Dockerfile
55+
push: true
56+
tags: dolthub/doltgresql:${{ github.event.inputs.version || github.event.client_payload.version }} , dolthub/doltgresql:latest
57+
build-args: |
58+
DOLTGRES_VERSION=${{ github.event.inputs.version || github.event.client_payload.version }}
59+
- name: Update Docker Hub Readme for doltgres image
60+
uses: peter-evans/dockerhub-description@v4
61+
with:
62+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
63+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
64+
repository: dolthub/doltgresql
65+
readme-filepath: ./dockerREADME.md
66+
- run: |
67+
gh api \
68+
--method PATCH \
69+
-H "Accept: application/vnd.github+json" \
70+
-H "X-GitHub-Api-Version: 2022-11-28" \
71+
/repos/$REPO_OWNER/$REPO_NAME/releases/$RELEASE_ID \
72+
-F "draft=false" -F "prerelease=false" -F "make_latest=true"
73+
env:
74+
GH_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
75+
REPO_OWNER: dolthub
76+
REPO_NAME: dolt
77+
RELEASE_ID: ${{ needs.get-release-id.outputs.release_id }}

.github/workflows/cd-release.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ jobs:
123123
tag_name: v${{ needs.format-version.outputs.version }}
124124
release_name: ${{ needs.format-version.outputs.version }}
125125
draft: false
126+
prerelease: true
126127
commitish: ${{ steps.build_binaries.outputs.commitish }}
127128
- name: Create install script
128129
id: create-install-script
@@ -222,3 +223,14 @@ jobs:
222223
token: ${{ secrets.REPO_ACCESS_TOKEN }}
223224
event-type: release-doltgres
224225
client-payload: '{"version": "${{ needs.format-version.outputs.version }}", "actor": "${{ github.actor }}"}'
226+
227+
docker-image-push:
228+
needs: [format-version, create-release]
229+
runs-on: ubuntu-22.04
230+
steps:
231+
- name: Trigger Push Docker Image
232+
uses: peter-evans/repository-dispatch@v3
233+
with:
234+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
235+
event-type: push-docker-image
236+
client-payload: '{"version": "${{ needs.format-version.outputs.version }}", "release_id": "${{ needs.create-pgo-release.outputs.release_id }}" }'

dockerREADME.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Doltgres is Dolt for Postgres!
2+
3+
From the creators of [Dolt](https://www.doltdb.com), the world's first version-controlled SQL
4+
database, comes [Doltgres](https://www.doltgres.com), the Postgres-flavored version of Dolt. It's a
5+
SQL database that you can branch and merge, fork and clone, push and pull, just like a Git
6+
repository. Connect to your Doltgres server just like any Postgres database to read or modify schema
7+
and data. Version control functionality is exposed in SQL via system tables, functions, and
8+
procedures.
9+
10+
Git versions file, Doltgres versions tables. It's like Git and Postgres had a baby.
11+
12+
[Join us on Discord](https://discord.com/invite/RFwfYpu) to say hi and
13+
ask questions, or [check out our roadmap](https://docs.dolthub.com/other/roadmap)
14+
to see what we're building next.
15+
16+
## What's it for?
17+
18+
Lots of things! Doltgres is a generally useful tool with countless applications. But if you want
19+
some ideas, [here's how people are using it so
20+
far](https://www.dolthub.com/blog/2022-07-11-dolt-case-studies/).
21+
22+
# How to use this image
23+
24+
This image is for the Doltgres server and is similar to the Postgres Docker image. Running this
25+
image without any arguments is equivalent to running the `doltgres` command inside a Docker
26+
container.
27+
28+
To see all supported options for `doltgres`, you can run the image with `--help` flag.
29+
30+
```shell
31+
$ docker run dolthub/doltgresql:latest --help
32+
```
33+
34+
## Building the image
35+
36+
To build this image, use the `Dockerfile` in the root of the [Doltgres
37+
repository](https://github.com/dolthub/doltgresql/) with an optional build argument:
38+
39+
```shell
40+
# Build the latest Doltgres version (automatically fetches the latest release)
41+
$ docker build -t doltgres:latest .
42+
43+
# Build the latest Doltgres version (fetches the latest release)
44+
$ docker build --build-arg DOLTGRES_VERSION=latest -t doltgres:latest .
45+
46+
# Build with a specific Doltgres version
47+
$ docker build --build-arg DOLTGRES_VERSION=0.55.1 -t doltgres:0.55.1 .
48+
49+
# Build from local source code
50+
$ docker build --build-arg DOLTGRES_VERSION=source -t doltgres:source .
51+
```
52+
53+
## Connect to the server in the container from the host system
54+
55+
To connect to a server running in a container from the host system, we need to map a port on the
56+
host system to the port our server is running on in the container.
57+
58+
```bash
59+
$ docker run -p 5432:5432 dolthub/doltgresql:latest
60+
```
61+
62+
*Note*: if you have Postgres installed on this machine already, port `5432` will be in use. Either
63+
choose a different port to map or shut down Postgres.
64+
65+
Now connect with `psql` or another Postgres-compatible client.
66+
67+
```bash
68+
$ PGPASSWORD=password psql --host 127.0.0.1 -U postgres
69+
```
70+
71+
## Define configuration for the server
72+
73+
You can specify server configuration by providing your own `config.yaml` for the server to use as a
74+
mounted volume. The image looks for a `config.yaml` file in the mounted directory
75+
`/etc/doltgres/servercfg.d`. Place your desired `config.yaml` directory in a local file, then
76+
provide it to `docker run` with the `-v` argument like this:
77+
78+
```shell
79+
$ docker run -v ./doltgres_cfg:/etc/doltgres/servercfg.d -p 5432:5432 dolthub/doltgresql:latest
80+
```
81+
82+
The data directory in the container is `/var/lib/doltgresql/`. To change this, provide the `PGDATA`
83+
or `DOLTGRES_DATA` environment variable to `docker run`. This directory can also be a mounted
84+
directory on the local machine.
85+
86+
```shell
87+
$ docker run -e PGDATA=/path/to/doltgres/data -p 5432:5432 dolthub/doltgresql:latest
88+
```
89+
90+
## Specifying a username and password
91+
92+
By default, the server creates a super-user named `postgres` with the password `password`. To change
93+
this, provide the `DOLTGRES_USER` and `DOLTGRES_PASSWORD` environment variables to the `docker run`
94+
command.
95+
96+
```shell
97+
$ docker run -e DOLTGRES_USER=myuser -e DOLTGRES_PASSWORD=mypass -p 5432:5432 dolthub/doltgresql:latest
98+
```
99+
100+
For convenience, `POSTGRES_USER` and `POSTGRES_PASSWORD` are accepted as aliases for these variables.
101+
102+
To create additional users, connect to the running database and issue `CREATE ROLE` and `GRANT`
103+
statements as the super-user.
104+
105+
## Environment Variables
106+
107+
The Doltgres image supports the following environment variables:
108+
109+
- `DOLTGRES_USER`: The name of the super-user (default: `postgres`). `POSTGRES_USER` is an alias.
110+
- `DOLTGRES_PASSWORD`: The password for the super-user (default: `password`). `POSTGRES_PASSWORD` is
111+
an alias.
112+
- `DOLTGRES_DATA`: Specifies a path in the container to store database data, created if it doesn't
113+
exist (default: `/var/lib/doltgresql/`). `PGDATA` is an alias.
114+
- `DOLTGRES_DB`: Specifies a database name to be created (default: none). The `postgres` database is
115+
still created.

scripts/build_all_binaries.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
# GO_BUILD_VERSION is the major version of Go to target, e.g. 1.25. Must be set in ENV.
1111

12-
set -e
12+
set -ex
1313
set -o pipefail
1414

1515
script_dir=$(dirname "$0")

0 commit comments

Comments
 (0)