From ca52dee83648561fc8e8b8f39e5e2c287ff8181c Mon Sep 17 00:00:00 2001 From: Thilo Behnke Date: Sat, 11 Jun 2022 18:51:47 +0200 Subject: [PATCH] dockerizing wip --- .dockerignore | 4 ++++ client/.dockerignore | 4 ++++ client/Dockerfile | 33 +++++++++++++++++++++++++++++++++ client/nginx/Dockerfile | 3 --- docker-compose.yml | 5 +++-- 5 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 client/.dockerignore create mode 100644 client/Dockerfile delete mode 100644 client/nginx/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..338a91b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.idea +.github +/pkg +/target diff --git a/client/.dockerignore b/client/.dockerignore new file mode 100644 index 0000000..735fddc --- /dev/null +++ b/client/.dockerignore @@ -0,0 +1,4 @@ +/pkg +/tests +/www/dist +/www/node_modules diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..f612d43 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,33 @@ +FROM rust:latest as rust_build_stage + +RUN apt-get update && apt-get upgrade -y +RUN apt-get install curl + +RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + +RUN mkdir /build +ADD ./pong /build/pong +ADD ./client /build/client +WORKDIR /build/client +RUN wasm-pack build + +FROM node:12 as www_build_stage + +RUN mkdir /build +ADD ./client/www /build +WORKDIR /build + +COPY --from=rust_build_stage /build/client/pkg/ /build/pkg/ + +RUN ls /build +RUN ls /build/pkg + +RUN npm install +RUN npm run build + +FROM nginx:latest + +COPY --from=www_build_stage /build/www/dist/ /usr/share/pong/ + +COPY ./client/nginx/default.conf /etc/nginx/conf.d/default.conf +COPY ./client/nginx/nginx.conf /etc/nginx/nginx.conf diff --git a/client/nginx/Dockerfile b/client/nginx/Dockerfile deleted file mode 100644 index ca2a03d..0000000 --- a/client/nginx/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM nginx:latest -COPY default.conf /etc/nginx/conf.d/default.conf -COPY nginx.conf /etc/nginx/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index e6af638..cecaf69 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: kafka: container_name: pong_server_kafka build: - context: ./server/kafka + context: ./kafka ports: - '9092:9092' - '9093:9093' @@ -28,7 +28,8 @@ services: nginx: container_name: pong_nginx build: - context: ./nginx + context: ./ + dockerfile: ./client/Dockerfile ports: - '80:80' network_mode: 'host'