Docker

2020-05-17

Dependencies

Steps

Create a file Dockerfile with the following contents. Remember to edit the rapu names to match your application name.

# https://hub.docker.com/_/rust/#! 2020-04-14
FROM rust:1.40 as builder
WORKDIR /usr/src/rapu
COPY . .
RUN cargo install --path .

FROM debian:buster-slim
# RUN apt-get update && apt-get install -y extra-runtime-dependencies-here-if-you-need-any
COPY --from=builder /usr/local/cargo/bin/rapu /usr/local/bin/rapu
EXPOSE 8080
ENV PORT 8080
CMD ["rapu"]

Create a file .dockerignore

target

You can now build your application with

docker build .

Optional

docker-compose can make running dockerized applications locally much more convenient.

Create a docker-compose.yaml file. Remember to replace rapu with your application name.

version: "2.0"
services:
  rapu:
    build: .
    ports:
      - "8080:8080"

Run docker-compose up --build to start your application.