Skip to content

Commit

Permalink
Docker Support (#94)
Browse files Browse the repository at this point in the history
* proposed dockerfile

* cleaned up args and added readme section
  • Loading branch information
ericjohnson97 authored Mar 15, 2024
1 parent 821d19d commit d5b6442
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dockerfile
README.md
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Build
FROM rust:alpine as builder
ARG TARGET_ARCH=x86_64-unknown-linux-musl

RUN apk add --no-cache musl-dev alpine-sdk
WORKDIR /usr/src/mavlink2rest
COPY . .

RUN rustup target add ${TARGET_ARCH}

RUN cargo build --release --target=${TARGET_ARCH}


# Runtime environment
FROM alpine
WORKDIR /root/

ARG TARGET_ARCH=x86_64-unknown-linux-musl

COPY --from=builder /usr/src/mavlink2rest/target/${TARGET_ARCH}/release/mavlink2rest ./mavlink2rest

ENV MAVLINK_SRC="udpin:0.0.0.0:14550"
ENV SERVER_PORT="0.0.0.0:8088"
ENV EXTRA_ARGS=""

RUN chmod +x mavlink2rest

ENTRYPOINT ./mavlink2rest -c ${MAVLINK_SRC} -s ${SERVER_PORT} ${EXTRA_ARGS}
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,33 @@ OPTIONS:
--system-id <SYSTEM_ID> Sets system ID for this service. [default: 255]
```
# Using Docker with mavlink2rest

You can also use the `mavlink2rest` with docker, the following command will start the service with the default settings:
```sh
docker run --rm --init -p 8088:8088 -p 14550:14550/udp --name mavlink2rest mavlink/mavlink2rest
```

The Dockerfile defines several environment variables that you can override at runtime:

MAVLINK_SRC: The MAVLink source connection string. Default is udpin:127.0.0.1:14550.
SERVER_PORT: The IP and port for the REST server. Default is 0.0.0.0:8088.
EXTRA_ARGS: Any additional command line arguments you want to pass to mavlink2rest.
To customize these settings, use the -e flag with docker run:

```sh
docker run --rm --init\
-p 8088:8088 \
-p 14551:14551/udp \
-e MAVLINK_SRC="udpin:0.0.0.0:14551" \
-e SERVER_PORT="0.0.0.0:8088" \
--name mavlink2rest mavlink/mavlink2rest
```

to build the docker image locally, you can use the following command:
```sh
docker build --build-arg TARGET_ARCH=x86_64-unknown-linux-musl -t mavlink/mavlink2rest .
```

## Endpoints

Expand Down

0 comments on commit d5b6442

Please sign in to comment.