2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 03:11:24 +00:00

Adding docker and docker-compose.

This commit is contained in:
Dessalines 2020-06-07 16:21:25 -04:00
parent 35aca6a426
commit a7bc7c0121
5 changed files with 58 additions and 2 deletions

3
.dockerignore Normal file
View file

@ -0,0 +1,3 @@
target
.git
docker/volumes

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/target
/data
/docker/volumes

30
docker/Dockerfile Normal file
View file

@ -0,0 +1,30 @@
# Build
FROM ekidd/rust-musl-builder:1.42.0-openssl11 as rust
# Cache deps
WORKDIR /app
RUN sudo chown -R rust:rust .
RUN USER=root cargo new server
WORKDIR /app/server
COPY Cargo.toml Cargo.lock ./
RUN sudo chown -R rust:rust .
RUN mkdir -p ./src/bin \
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
RUN cargo build --release
RUN rm -f ./target/x86_64-unknown-linux-musl/release/deps/pict_rs*
COPY src ./src/
# Build for release
RUN cargo build --frozen --release
FROM alpine:3.10
# Copy resources
COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/release/pict-rs /app/pict-rs
RUN addgroup -g 1000 pictrs
RUN adduser -D -s /bin/sh -u 1000 -G pictrs pictrs
RUN chown pictrs:pictrs /app/pict-rs
USER pictrs
EXPOSE 8080
CMD ["/app/pict-rs"]

15
docker/docker-compose.yml Normal file
View file

@ -0,0 +1,15 @@
version: '3.3'
services:
pictrs:
build:
context: ../
dockerfile: docker/Dockerfile
user: root
ports:
- "127.0.0.1:8080:8080"
restart: always
environment:
- PICTRS_PATH=/app/data
volumes:
- ./volumes/pictrs:/app/data

View file

@ -5,16 +5,23 @@ pub(crate) struct Config {
#[structopt(
short,
long,
help = "The address and port the server binds to, e.g. 127.0.0.1:80"
env = "PICTRS_ADDR",
default_value = "0.0.0.0:8080",
help = "The address and port the server binds to. Default: 0.0.0.0:8080"
)]
addr: SocketAddr,
#[structopt(short, long, help = "The path to the data directory, e.g. data/")]
#[structopt(
short,
long,
env = "PICTRS_PATH",
help = "The path to the data directory, e.g. data/")]
path: PathBuf,
#[structopt(
short,
long,
env = "PICTRS_FORMAT",
help = "An image format to convert all uploaded files into, supports 'jpg' and 'png'"
)]
format: Option<Format>,