Skip to content

Commit 756f15e

Browse files
committed
fix: config files
1 parent 4d8287c commit 756f15e

File tree

9 files changed

+41
-19
lines changed

9 files changed

+41
-19
lines changed

Dockerfile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,30 @@ COPY . .
2020
RUN cargo build --release --all
2121
RUN mv target/${CARGO_BUILD_TARGET}/release /out
2222

23-
FROM scratch AS prod
23+
FROM scratch AS public_server_prod
2424
WORKDIR /user
2525
COPY src/public/config/00-default.toml 00-default.toml
26-
COPY --from=builder /out/cli /usr/local/bin/rust-server
27-
ENTRYPOINT ["/usr/local/bin/rust-server", "--config-path=*.toml"]
26+
COPY --from=builder /out/public_server /usr/local/bin/public_server
27+
ENTRYPOINT ["/usr/local/bin/public_server", "--config-path=*.toml"]
2828

29-
FROM alpine AS dev
29+
FROM alpine AS public_server_dev
3030
WORKDIR /user
3131
COPY src/public/config/00-default.toml 00-default.toml
32-
COPY --from=builder /out/cli /usr/local/bin/rust-server
32+
COPY --from=builder /out/public_server /usr/local/bin/public_server
3333
COPY --from=bunyan /root/.cargo/bin/bunyan /usr/local/bin/
3434
ENTRYPOINT ["/bin/sh"]
35-
CMD ["-c", "/usr/local/bin/rust-server --config-path=*.toml | bunyan"]
35+
CMD ["-c", "/usr/local/bin/public_server --config-path=*.toml | bunyan"]
36+
37+
FROM scratch AS gpt_answer_server_prod
38+
WORKDIR /user
39+
COPY src/public/config/00-default.toml 00-default.toml
40+
COPY --from=builder /out/public_server /usr/local/bin/public_server
41+
ENTRYPOINT ["/usr/local/bin/public_server", "--config-path=*.toml"]
42+
43+
FROM alpine AS gpt_answer_server_dev
44+
WORKDIR /user
45+
COPY src/public/config/00-default.toml 00-default.toml
46+
COPY --from=builder /out/public_server /usr/local/bin/public_server
47+
COPY --from=bunyan /root/.cargo/bin/bunyan /usr/local/bin/
48+
ENTRYPOINT ["/bin/sh"]
49+
CMD ["-c", "/usr/local/bin/public_server --config-path=*.toml | bunyan"]

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ build:
2828
PKG_NAME=rust-api-server
2929
BUILD_VERSION=$(shell git describe --long)
3030
BUILD_RELEASE=$(shell git describe --tags --abbrev=0)
31-
BUILDKIT_PROGRESS=plain
32-
DOCKER_BUILDKIT=1
33-
docker build --ssh default -t $(PKG_NAME):$(BUILD_VERSION) --target=prod .
31+
BUILDKIT_PROGRESS=plain docker build --ssh default -t $(PKG_NAME):$(BUILD_VERSION) --target=public_server_prod .
32+
BUILDKIT_PROGRESS=plain docker build --ssh default -t $(PKG_NAME):$(BUILD_VERSION) --target=gpt_answer_server_prod .
3433

3534
build-dev:
36-
BUILDKIT_PROGRESS=plain DOCKER_BUILDKIT=1 docker build --ssh default -t $(PKG_NAME):$(BUILD_VERSION) --target=dev .
35+
BUILDKIT_PROGRESS=plain DOCKER_BUILDKIT=1 docker build --ssh default -t $(PKG_NAME):$(BUILD_VERSION) --target=public_server_dev .
36+
BUILDKIT_PROGRESS=plain DOCKER_BUILDKIT=1 docker build --ssh default -t $(PKG_NAME):$(BUILD_VERSION) --target=gpt_answer_server_dev .
3737

3838
profiling-public:
3939
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --root -- -c ./src/public/config/* -c ./deploy/local/custom.toml

deploy/docker/01-custom.toml renamed to deploy/docker/01_public_custom.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ url = "postgres://postgres:changeme@postgres:5432/postgres"
1313
max_size = 10
1414

1515
[redis]
16-
host = "0.0.0.0"
16+
host = "redis"
1717
port = 6379

deploy/docker/docker-compose.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ services:
3333
- postgres:/data/postgres
3434
ports:
3535
- "5432:5432"
36-
server:
37-
image: rust-server
36+
public_server:
37+
image: public_server
3838
build:
3939
context: ../..
40-
target: dev
40+
target: public_server_dev
4141
ports:
4242
- "8888:8888"
4343
volumes:

deploy/local/docker-compose.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@ services:
3333
- postgres:/data/postgres
3434
ports:
3535
- "5432:5432"
36+
redis:
37+
image: redis:alpine
38+
ports:
39+
- "6379:6379"
3640
volumes:
3741
postgres:

deploy/local/custom.toml renamed to deploy/local/public_custom.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ level = "info"
88

99
[db.pg]
1010
url = "postgres://postgres:changeme@localhost:5432/postgres"
11-
max_size = 100
11+
max_size = 100
12+
13+
[redis]
14+
host = "0.0.0.0"
15+
port = 6379
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
service_name = "rust-grpc-server"
1+
service_name = "gpt_answer_server"
22
exporter_endpoint = "http://localhost:7281"
33
server_endpoint = "0.0.0.0:50051"
44

55
[redis]
6-
host = "0.0.0.0"
6+
host = "redis"
77
port = 6379

src/public/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ example = []
33

44
[[bin]]
55
path = "src/main.rs"
6-
name = "cli"
6+
name = "public_server"
77
test = true
88
doctest = true
99
bench = true

src/public/config/00-default.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
service_name = "rust-api-server"
1+
service_name = "public_server"
22
exporter_endpoint = "http://localhost:7281"
33
gpt_answer_service_url = "grpc://0.0.0.0:50051"
44

0 commit comments

Comments
 (0)