https://github.com/cockroachlabs-field/cockroachdb-single-node
Simple Docker image that starts a single CockroachDB database node. Great for CI/CD pipelines!
https://github.com/cockroachlabs-field/cockroachdb-single-node
cockroachdb docker github-actions
Last synced: over 1 year ago
JSON representation
Simple Docker image that starts a single CockroachDB database node. Great for CI/CD pipelines!
- Host: GitHub
- URL: https://github.com/cockroachlabs-field/cockroachdb-single-node
- Owner: cockroachlabs-field
- Created: 2021-10-06T20:26:25.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-24T22:49:49.000Z (over 3 years ago)
- Last Synced: 2024-01-22T18:06:32.188Z (over 2 years ago)
- Topics: cockroachdb, docker, github-actions
- Language: Shell
- Homepage:
- Size: 13.7 KB
- Stars: 4
- Watchers: 0
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CockroachDB Single Node
This project creates a simple [CockroachDB](https://www.cockroachlabs.com/) Docker image that is ideal for use in CI/CD pipelines or other functional tests. The `Dockerfile` extends the latest CockroachDB [image](https://hub.docker.com/r/cockroachdb/cockroach), automatically [starts a single node](https://www.cockroachlabs.com/docs/stable/cockroach-start-single-node.html), and can automatically create a database if the environment variable `DATABASE_NAME` is provided. If the environment variable `MEMORY_SIZE` is provided, CockroachDB will be started with an in-memory store with the given [size](https://www.cockroachlabs.com/docs/stable/cockroach-start-single-node.html#store). The image is hosted on DockerHub and can be found [here](https://hub.docker.com/repository/docker/timveil/cockroachdb-single-node).
This project is especially useful when attempting to use CockroachDB as a [Service Container](https://docs.github.com/en/actions/using-containerized-services/about-service-containers) inside GitHub Actions. Below is a snippet from a GitHub action `yml` file. Notice the `cockroach` service defined as part of the `cockroachdb` job. The `DATABASE_NAME` is provided as an `env` value.
```yaml
# stuff happens above this...
cockroachdb:
runs-on: ubuntu-latest
services:
cockroach: # https://hub.docker.com/repository/docker/timveil/cockroachdb-single-node
image: timveil/cockroachdb-single-node:latest
env:
DATABASE_NAME: benchbase
ports:
- 26257:26257
steps:
- name: Checkout repo.
uses: actions/checkout@v2
- name: Setup JDK 11.
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Maven.
run: mvn -B package --file pom.xml
# stuff happens below this...
```
## Building the Image
```bash
docker build --no-cache -t timveil/cockroachdb-single-node:latest .
```
## Publishing the Image
```bash
docker push timveil/cockroachdb-single-node:latest
```
## Running the Image
```bash
docker run -d -it -p 8080:8080 -p 26257:26257 -e "DATABASE_NAME=test" -e "MEMORY_SIZE=.5" timveil/cockroachdb-single-node:latest
```