Skip to content

Commit

Permalink
docker in ci/cd (#92)
Browse files Browse the repository at this point in the history
* remove redundant chown

* remove redundant port, naming consistency

* md lint

* docker test  in ci

* fix docker test

* cleanup in docker test

* more cleanupgs

* wait

* wip

* fix docker test

* try fix

* use cache for speed

* try fixg

* logs

* debugging

* caching

* use buildx

* logs

* buildx output

* try docker build action

* add host

* remove useless caching

* update readme

* update readme

* test dockerhub push

* update readme

* update test

* update test

* remove ci docker push test
  • Loading branch information
achristmascarl authored Sep 19, 2024
1 parent f41002b commit 3d0d521
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 43 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,28 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker-push:
name: Docker Build and Push
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker CLI
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
push: true
context: .
tags: achristmascarl/rainfrog:latest,achristmascarl/rainfrog:${{ github.ref }}
cache-from: type=gha
cache-to: type=gha,mode=max`

publish-cargo:
name: Publishing to Cargo
runs-on: ubuntu-latest
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,41 @@ jobs:
if: ${{ matrix.target == null }}
run: cargo test --features ${{ matrix.features }} --workspace

docker:
name: Test Docker
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: build docker image
run: |
docker build . -t rainfrog_test
- name: init db for docker test
run: |
make db-up
sleep 5 # wait for db container
- name: docker run
run: |
docker run -dit --name rainfrog_test \
--add-host host.docker.internal:host-gateway \
-e username="root" \
-e password="password" \
-e hostname="host.docker.internal" \
-e db_port="5499" \
-e db_name="rainfrog" rainfrog_test
sleep 5 # wait for container
- name: check container status
run: |
container_status=$(docker ps -f name=rainfrog_test --format "{{.Status}}")
if [[ "$container_status" == "Up"* ]]; then
echo "container started"
else
echo "container did not start"
echo "logs: "
docker logs -t rainfrog_test
exit 1
fi
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ RUN useradd -m -s /bin/bash rainfrog
# Copy the binary from the builder image
COPY --from=builder /app/target/release/rainfrog /usr/local/bin/rainfrog

# Change ownership of the files to the non-root user
RUN chown -R rainfrog:rainfrog /usr/src/app
USER rainfrog

HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD pidof rainfrog || exit 1

# Command to construct the full connection URL using environment variables
CMD ["bash", "-c", "rainfrog --url postgres://$username:$password@$hostname:$db_port/$dbname"]
CMD ["bash", "-c", "rainfrog --url postgres://$username:$password@$hostname:$db_port/$db_name"]
74 changes: 34 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,23 @@ curl -LSsf https://raw.githubusercontent.com/achristmascarl/rainfrog/main/instal
## usage

> [!NOTE]
> `connection_url` must include your credentials for accessing the database (ex. `postgres://username:password@localhost:5432/postgres`)
> the `connection_url` must include your credentials for accessing
> the database (ex. `postgres://username:password@localhost:5432/postgres`)
```sh
rainfrog --url $(connection_url)
```

### `docker run`

> [!NOTE]
> For now we build the image locally until the image is available in Docker Hub
```sh
docker build . -t rainfrog
```

```sh
docker run -it --rm --name rainfrog \
-p <db_port>:<db_port> \
docker run --platform linux/amd64 -it --rm --name rainfrog \
--add-host host.docker.internal:host-gateway \
-e username="<username>" \
-e password="<password>" \
-e hostname="host.docker.internal" \
-e db_port="<db_port>" \
-e dbname="<dbname>" rainfrog
-e db_name="<db_name>" achristmascarl/rainfrog:latest
```

## keybindings
Expand Down Expand Up @@ -152,35 +146,35 @@ docker run -it --rm --name rainfrog \

Keybindings may not behave exactly like Vim. The full list of active Vim keybindings in Rainfrog can be found at [vim.rs](./src/vim.rs).

| Keybinding | Description |
|---------------------------|----------------------------------------|
| `Alt+Enter`, `F5` | Execute query |
| `j`, `↓` | Move cursor down 1 line |
| `k`, `↑` | Move cursor up 1 line |
| `h`, `←` | Move cursor left 1 char |
| `l`, `β†’` | Move cursor right 1 char |
| `w` | Move cursor to next start of word |
| `e` | Move cursor to next end of word |
| `b` | Move cursor to previous start of word |
| `0` | Move cursor to beginning of line |
| `$` | Move cursor to end of line |
| `gg` | Jump to top of editor |
| `G` | Jump to bottom of current list |
| `Esc` | Return to normal mode |
| `i` | Enter insert (edit) mode |
| `I` | Enter insert mode at beginning of line |
| `A` | Enter insert mode at end of line |
| `o` | Insert new line below and enter insert |
| `v` | Enter visual (select) mode |
| `V` | Enter visual mode and select line |
| `r` | Begin replace operation |
| `y` | Begin yank (copy) operation |
| `x` | Begin cut operation |
| `p` | Paste from clipboard |
| `u` | Undo |
| `Ctrl+r` | Redo |
| `Ctrl+e` | Scroll down |
| `Ctrl+y` | Scroll up |
| Keybinding | Description |
| ----------------- | -------------------------------------- |
| `Alt+Enter`, `F5` | Execute query |
| `j`, `↓` | Move cursor down 1 line |
| `k`, `↑` | Move cursor up 1 line |
| `h`, `←` | Move cursor left 1 char |
| `l`, `β†’` | Move cursor right 1 char |
| `w` | Move cursor to next start of word |
| `e` | Move cursor to next end of word |
| `b` | Move cursor to previous start of word |
| `0` | Move cursor to beginning of line |
| `$` | Move cursor to end of line |
| `gg` | Jump to top of editor |
| `G` | Jump to bottom of current list |
| `Esc` | Return to normal mode |
| `i` | Enter insert (edit) mode |
| `I` | Enter insert mode at beginning of line |
| `A` | Enter insert mode at end of line |
| `o` | Insert new line below and enter insert |
| `v` | Enter visual (select) mode |
| `V` | Enter visual mode and select line |
| `r` | Begin replace operation |
| `y` | Begin yank (copy) operation |
| `x` | Begin cut operation |
| `p` | Paste from clipboard |
| `u` | Undo |
| `Ctrl+r` | Redo |
| `Ctrl+e` | Scroll down |
| `Ctrl+y` | Scroll up |

### query history

Expand Down

0 comments on commit 3d0d521

Please sign in to comment.