Skip to content

Commit 9861629

Browse files
authored
Layered docker images and improved docker-compose deployment (#282)
* update docker compose and add layered docker images for kitsune and kitsune-search-server * consistent Dockerfiles * use stable in the Dockerfiles
1 parent 74cc110 commit 9861629

File tree

7 files changed

+133
-37
lines changed

7 files changed

+133
-37
lines changed

.dockerignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
**/node_modules
22
target/
3-
kitsune-fe/
43
Dockerfile.dev
54
Dockerfile.prod

config.docker.toml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[cache]
2+
type = "in-memory"
3+
4+
[database]
5+
url = "postgres://kitsune:password@db/kitsune"
6+
max-connections = 20
7+
8+
[instance]
9+
name = "Kitsune"
10+
description = "https://www.youtube.com/watch?v=6lnnPnr_0SU"
11+
character-limit = 5000
12+
registrations-open = true
13+
14+
[instance.federation-filter]
15+
type = "deny"
16+
domains = []
17+
18+
[job-queue]
19+
redis-url = "redis://redis"
20+
num-workers = 20
21+
22+
[messaging]
23+
type = "in-process"
24+
25+
[server]
26+
frontend-dir = "./kitsune-fe/dist"
27+
max-upload-size = 5242880 # 5MB
28+
media-proxy-enabled = false
29+
port = 5000
30+
prometheus-port = 9000
31+
request-timeout-secs = 60
32+
33+
[search]
34+
type = "sql"
35+
36+
[storage]
37+
type = "fs"
38+
upload-dir = "./uploads"
39+
40+
[url]
41+
scheme = "http"
42+
domain = "localhost:5000"

docker-compose.yml

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ version: '3.1'
33
services:
44
backend:
55
image: kitsune
6+
command:
7+
- config.toml
68
ports:
79
- "5000:5000"
810
networks:
@@ -18,6 +20,13 @@ services:
1820
SEARCH_SERVERS: http://backend-search:8080
1921
volumes:
2022
- upload-data:/app/uploads
23+
- type: bind
24+
source: ${KITSUNE_CONFIG}
25+
target: /app/config.toml
26+
read_only: true
27+
depends_on:
28+
- db
29+
- redis
2130

2231
backend-search:
2332
image: kitsune-search

kitsune-search-server/Dockerfile.dev

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
FROM rust:1-alpine AS build
2-
RUN rustup default nightly
3-
RUN apk add --no-cache musl-dev
4-
COPY . /build
5-
WORKDIR /build
6-
RUN cargo -Z sparse-registry build
1+
FROM rust:1-alpine AS base
2+
RUN apk add --no-cache musl-dev make protobuf-dev
3+
RUN cargo install cargo-chef
4+
WORKDIR app
5+
6+
FROM base AS planner
7+
COPY . .
8+
RUN cargo chef prepare --recipe-path recipe.json
9+
10+
FROM base AS build
11+
COPY --from=planner /app/recipe.json recipe.json
12+
RUN cargo chef cook --recipe-path recipe.json
13+
COPY . .
14+
RUN cargo build --bin kitsune-search-server
715

816
FROM alpine:latest
9-
WORKDIR /app
10-
COPY --from=build /build/target/debug/kitsune-search .
11-
CMD ["/app/kitsune-search"]
17+
WORKDIR app
18+
COPY --from=build /app/target/debug/kitsune-search-server .
19+
ENTRYPOINT ["./kitsune-search-server"]

kitsune-search-server/Dockerfile.prod

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
FROM rust:1-alpine AS build
2-
RUN rustup default nightly
3-
RUN apk add --no-cache musl-dev
4-
COPY . /build
5-
WORKDIR /build
6-
RUN cargo -Z sparse-registry build --release
1+
FROM rust:1-alpine AS base
2+
RUN apk add --no-cache musl-dev make protobuf-dev
3+
RUN cargo install cargo-chef
4+
WORKDIR app
5+
6+
FROM base AS planner
7+
COPY . .
8+
RUN cargo chef prepare --recipe-path recipe.json
9+
10+
FROM base AS build
11+
COPY --from=planner /app/recipe.json recipe.json
12+
RUN cargo chef cook --release --recipe-path recipe.json
13+
COPY . .
14+
RUN cargo build --release --bin kitsune-search-server
715

816
FROM alpine:latest
9-
WORKDIR /app
10-
COPY --from=build /build/target/release/kitsune-search .
11-
CMD ["/app/kitsune-search"]
17+
WORKDIR app
18+
COPY --from=build /app/target/release/kitsune-search-server .
19+
ENTRYPOINT ["./kitsune-search-server"]

kitsune/Dockerfile.dev

+24-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
FROM rust:1-alpine AS build
2-
RUN rustup default nightly
3-
RUN apk add --no-cache musl-dev
4-
COPY . /build
5-
WORKDIR /build
6-
RUN cargo -Z sparse-registry build
1+
FROM rust:1-alpine AS base
2+
RUN apk add --no-cache musl-dev make protobuf-dev
3+
RUN cargo install cargo-chef
4+
WORKDIR app
5+
6+
FROM base AS planner
7+
COPY . .
8+
RUN cargo chef prepare --recipe-path recipe.json
9+
10+
FROM base AS build
11+
COPY --from=planner /app/recipe.json recipe.json
12+
RUN cargo chef cook --recipe-path recipe.json
13+
COPY . .
14+
RUN cargo build --bin kitsune
15+
16+
FROM base AS frontend
17+
RUN apk add --no-cache yarn
18+
COPY kitsune-fe .
19+
WORKDIR kitsune-fe
20+
RUN yarn install && yarn build
721

822
FROM alpine:latest
9-
WORKDIR /app
10-
COPY --from=build /build/target/debug/kitsune .
11-
CMD ["/app/kitsune"]
23+
WORKDIR app
24+
COPY --from=build /app/target/debug/kitsune .
25+
COPY --from=frontend /app kitsune-fe
26+
ENTRYPOINT ["./kitsune"]

kitsune/Dockerfile.prod

+24-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
FROM rust:1-alpine AS build
2-
RUN rustup default nightly
3-
RUN apk add --no-cache musl-dev
4-
COPY . /build
5-
WORKDIR /build
6-
RUN cargo -Z sparse-registry build --release
1+
FROM rust:1-alpine AS base
2+
RUN apk add --no-cache musl-dev make protobuf-dev
3+
RUN cargo install cargo-chef
4+
WORKDIR app
5+
6+
FROM base AS planner
7+
COPY . .
8+
RUN cargo chef prepare --recipe-path recipe.json
9+
10+
FROM base AS build
11+
COPY --from=planner /app/recipe.json recipe.json
12+
RUN cargo chef cook --release --recipe-path recipe.json
13+
COPY . .
14+
RUN cargo build --release --bin kitsune
15+
16+
FROM base AS frontend
17+
RUN apk add --no-cache yarn
18+
COPY kitsune-fe .
19+
WORKDIR kitsune-fe
20+
RUN yarn install && yarn build
721

822
FROM alpine:latest
9-
WORKDIR /app
10-
COPY --from=build /build/target/release/kitsune .
11-
CMD ["/app/kitsune"]
23+
WORKDIR app
24+
COPY --from=build /app/target/release/kitsune .
25+
COPY --from=frontend /app kitsune-fe
26+
ENTRYPOINT ["./kitsune"]

0 commit comments

Comments
 (0)