fix: finally docker/compose are set up correctly

This commit is contained in:
meeg_leeto 2022-04-24 23:50:32 +01:00
parent 97d19a5b80
commit c2d813e6c4
4 changed files with 18 additions and 10 deletions

View File

@ -1,5 +1,5 @@
# Prepare container
FROM rust:slim-buster
FROM rust:slim-buster as builder
RUN USER=root cargo new --bin lonk
WORKDIR /lonk
@ -17,10 +17,10 @@ RUN rm src/*.rs
COPY ./src ./src
RUN rm ./target/${PROFILE:-release}/deps/lonk*
RUN cargo build
RUN cp /lonk/target/${PROFILE:-debug}/lonk /bin/lonk
# Execution container
FROM rust:latest
FROM rust:slim-buster
WORKDIR /
ARG PROFILE
COPY --from=builder /lonk/target/${PROFILE:-release}/lonk .
CMD ["./lonk"]
COPY --from=builder /lonk/target/${PROFILE:-release}/lonk /bin/lonk
CMD ["/bin/lonk"]

View File

@ -1,6 +1,6 @@
{
"db": {
"address": "redis://db:6379",
"address": "redis://redis:6379",
"worker_threads": 4
},
"slug_rules": {
@ -12,7 +12,7 @@
"Dir": "/data/served"
},
"addr": {
"ip": "127.0.0.1",
"ip": "0.0.0.0",
"port": 8080
}
}

View File

@ -1,21 +1,25 @@
version: "3.9"
services:
lonk:
depends_on:
- redis
build:
context: .
args:
PROFILE: debug
environment:
- LONK_CONFIG="/data/config.json"
- LONK_CONFIG=/data/config.json
volumes:
- ./data:/data
ports:
- 8080:8892
- 8892:8080
redis:
image: 'redis:alpine'
command: redis-server --save 20 1 --loglevel warning
command: redis-server --save 20 1 --loglevel warning --port 6379
volumes:
- redis:/data
expose:
- 6379
volumes:
redis:
driver: local

View File

@ -326,6 +326,10 @@ async fn serve() {
let routes = warp::get().and(homepage.or(shorten).or(link));
println!(
"Now serving lonk at IP {}, port {}!",
config.serve_rules.addr.ip, config.serve_rules.addr.port
);
warp::serve(routes)
.run((config.serve_rules.addr.ip, config.serve_rules.addr.port))
.await;