Skip to content

Commit

Permalink
feat: add docker run
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Tupas <fred.tupas21@gmail.com>
  • Loading branch information
ftupas committed Sep 19, 2024
1 parent c340f7f commit 49142b4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM rust:alpine3.20 AS builder
WORKDIR /app

# Install system dependencies
RUN apk add --no-cache musl-dev=1.2.5-r0

# Build application
COPY . .
RUN cargo build --release

# Create runtime image
FROM debian:bookworm-slim AS runtime
WORKDIR /usr/src/app

# Create non-root user
RUN useradd -m -s /bin/bash rainfrog

# Copy the binary from the builder image
COPY --chmod=755 --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"]
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,32 @@ 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`)
> [!NOTE]
> `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> \
-e username="<username>" \
-e password="<password>" \
-e hostname="host.docker.internal" \
-e db_port="<db_port>" \
-e dbname="<dbname>" rainfrog
```

## keybindings

### general
Expand Down

0 comments on commit 49142b4

Please sign in to comment.