diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ccf3aa0..d7bed08 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb9ba58..d32e86e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 75a0fa8..22f6b6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md index c132b69..096e744 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,8 @@ 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) @@ -98,21 +99,14 @@ 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 : \ +docker run --platform linux/amd64 -it --rm --name rainfrog \ + --add-host host.docker.internal:host-gateway \ -e username="" \ -e password="" \ -e hostname="host.docker.internal" \ -e db_port="" \ - -e dbname="" rainfrog + -e db_name="" achristmascarl/rainfrog:latest ``` ## keybindings @@ -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