mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-12 22:41:01 +00:00
working backend on docker (#226)
* working backend on docker refactor of the dockerfiles to be more readable and independent. full build of the backend (release only) within docker * read `PORT` to u16 * Only need one `PORT` in the new backend Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
FROM rust
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY ./backend .
|
||||||
|
|
||||||
|
RUN cargo build --release
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
ENTRYPOINT [ "./target/release/telemetry" ]
|
||||||
+3
-1
@@ -87,6 +87,8 @@ fn main() -> std::io::Result<()> {
|
|||||||
let factory = LocatorFactory::new();
|
let factory = LocatorFactory::new();
|
||||||
let locator = SyncArbiter::start(4, move || factory.create());
|
let locator = SyncArbiter::start(4, move || factory.create());
|
||||||
|
|
||||||
|
let port = std::env::var("PORT").ok().and_then(|v| v.parse().ok()).unwrap_or(8000u16);
|
||||||
|
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
.data(aggregator.clone())
|
.data(aggregator.clone())
|
||||||
@@ -98,7 +100,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
.service(resource("/network_state/{chain}/{nid}").route(get().to_async(state_route)))
|
.service(resource("/network_state/{chain}/{nid}").route(get().to_async(state_route)))
|
||||||
.service(resource("/network_state/{chain}/{nid}/").route(get().to_async(state_route)))
|
.service(resource("/network_state/{chain}/{nid}/").route(get().to_async(state_route)))
|
||||||
})
|
})
|
||||||
.bind("0.0.0.0:8000")?
|
.bind(format!("0.0.0.0:{}", port))?
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
sys.run()
|
sys.run()
|
||||||
|
|||||||
+5
-8
@@ -3,9 +3,9 @@ version: "3"
|
|||||||
services:
|
services:
|
||||||
telemetry-frontend:
|
telemetry-frontend:
|
||||||
build:
|
build:
|
||||||
dockerfile: Dockerfile
|
dockerfile: frontend.Dockerfile
|
||||||
context: ./
|
context: ./
|
||||||
# Copy in changes to the ui, so no need to rebulld the images.
|
# Copy in changes to the ui, so no need to rebuild the images.
|
||||||
volumes:
|
volumes:
|
||||||
- /app/node_modules
|
- /app/node_modules
|
||||||
- ./packages:/app/packages
|
- ./packages:/app/packages
|
||||||
@@ -14,12 +14,9 @@ services:
|
|||||||
- 3000:3000
|
- 3000:3000
|
||||||
telemetry-backend:
|
telemetry-backend:
|
||||||
build:
|
build:
|
||||||
dockerfile: Dockerfile
|
dockerfile: backend.Dockerfile
|
||||||
context: ./
|
context: ./
|
||||||
command: yarn start:backend
|
|
||||||
environment:
|
environment:
|
||||||
- TELEMETRY_SERVER=1024
|
- PORT=8000
|
||||||
- FEED_SERVER=8080
|
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8000:8000
|
||||||
- 1024:1024
|
|
||||||
|
|||||||
@@ -5,13 +5,7 @@ WORKDIR /app
|
|||||||
RUN apk add --no-cache python make g++
|
RUN apk add --no-cache python make g++
|
||||||
|
|
||||||
COPY ./scripts ./scripts
|
COPY ./scripts ./scripts
|
||||||
COPY ./backend ./backend
|
|
||||||
COPY ./packages ./packages
|
COPY ./packages ./packages
|
||||||
COPY ./package.json ./yarn.lock ./tsconfig.json ./
|
COPY ./package.json ./yarn.lock ./tsconfig.json ./
|
||||||
|
|
||||||
RUN yarn
|
RUN yarn
|
||||||
|
|
||||||
|
|
||||||
# Frontend is exposing 3000
|
|
||||||
# Backend is exposing 8080
|
|
||||||
# No need for expose, if using docker-compose & docker run -p 3000:3000
|
|
||||||
Reference in New Issue
Block a user