From c882640da9d72787fc9c4bd19a2622362505ee3c Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 30 Nov 2018 17:14:02 -0700 Subject: [PATCH 1/2] Adding docker build. #19 --- .dockerignore | 6 ++++++ Dockerfile | 33 +++++++++++++++++++++++++++++++++ docker-compose.yml | 8 ++++++++ server/service/src/main.rs | 2 +- server/ui/src/env.ts | 2 +- 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7b106f9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +server/ui/node_modules +server/ui/dist +server/service/target +new_torrents_fetcher +scripts +.git \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c973574 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# Torrents.csv Dockerfile + +# Build front end resources +FROM node:10 AS node-builder + +ARG UI_PATH=/usr/app/server/ui +COPY server/ui ${UI_PATH} +WORKDIR ${UI_PATH} +ARG ENDPOINT_NAME=0.0.0.0:8080 + +RUN echo "export const endpoint = '${ENDPOINT_NAME}';" > src/env.ts +RUN yarn +RUN yarn build + +# Build back end +FROM rust:1.30 + +# Copy the torrents.csv file +COPY torrents.csv /usr/app/ + +# Creating a directory to work from +ARG SERVICE_PATH=/usr/app/server/service +COPY server/service ${SERVICE_PATH} +WORKDIR ${SERVICE_PATH} + +COPY --from=node-builder /usr/app/server/ui /usr/app/server/ui +RUN ls /usr/app +RUN ls /usr/app/server/ui +RUN ls /usr/app/server/ui/dist +RUN ls /usr/app/server/service + +# Build it +RUN cargo build --release diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ef9d321 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: '2' + +services: + torrents-csv: + build: . + command: "bash -c 'cd /usr/app/server/service; ls; cargo run --release'" + ports: + - "8080:8080" \ No newline at end of file diff --git a/server/service/src/main.rs b/server/service/src/main.rs index 14a3e0c..409ca8e 100644 --- a/server/service/src/main.rs +++ b/server/service/src/main.rs @@ -28,7 +28,7 @@ fn main() { // .index_file("index.html"), ) .finish() - }).bind("127.0.0.1:8080") + }).bind("0.0.0.0:8080") .unwrap() .run(); } diff --git a/server/ui/src/env.ts b/server/ui/src/env.ts index 67d4a31..61bc4ef 100644 --- a/server/ui/src/env.ts +++ b/server/ui/src/env.ts @@ -1 +1 @@ -export const endpoint = "http://localhost:8080"; \ No newline at end of file +export const endpoint = "http://0.0.0.0:8080"; \ No newline at end of file From 8c4f18bb43592e2ddc0a5c67d2240f0bf2651dc9 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 30 Nov 2018 17:16:17 -0700 Subject: [PATCH 2/2] Removing ls from docker-compose --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index ef9d321..af8b9f4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,6 @@ version: '2' services: torrents-csv: build: . - command: "bash -c 'cd /usr/app/server/service; ls; cargo run --release'" + command: bash -c "cd /usr/app/server/service; cargo run --release" ports: - "8080:8080" \ No newline at end of file