Skip to content

Commit

Permalink
feat: [torrust#11] docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Jul 6, 2022
1 parent 6e8292a commit c55d3fa
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git
.github
bin/docker/
data.db
storage/
target/
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/target
**/*.rs.bk
/database.json.bz2
/database.db
/.idea/
/config.toml
/data.db
/database.db
/database.json.bz2
/storage/data.db
/target
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM lukemathwalker/cargo-chef:latest-rust-1.62.0 AS chef
WORKDIR /app


FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json


FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release --bin torrust-tracker


FROM debian:bullseye-slim AS runtime
WORKDIR /app

ENV TZ=Etc/UTC \
APP_USER=appuser

RUN groupadd $APP_USER \
&& useradd -g $APP_USER $APP_USER \
&& mkdir -p /app

RUN chown -R $APP_USER:$APP_USER /app

RUN apt-get -y update \
&& apt-get -y upgrade \
&& apt-get install -y sqlite3 libssl1.1

EXPOSE 6969
EXPOSE 1212

COPY --from=builder /app/target/release/torrust-tracker /app

USER $APP_USER

ENTRYPOINT ["/app/torrust-tracker"]
3 changes: 3 additions & 0 deletions bin/docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker build -t torrust-tracker .
7 changes: 7 additions & 0 deletions bin/docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

docker run --rm -it \
-p 6969:6969 -p 1212:1212 \
--volume "$(pwd)/storage":"/app/storage" \
--mount type=bind,source="$(pwd)/config.toml",target=/app/config.toml \
torrust-tracker

0 comments on commit c55d3fa

Please sign in to comment.