From 33b9bd773f6ef7539179444525917ab711e1365f Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Fri, 8 Jan 2021 00:20:27 +0100 Subject: [PATCH 01/16] *: Dockerfiles cleanup, docker-compose.prod.yaml New docker-compose.prod.yaml should provide a production-ish deployment of WorkAdventure --- .dockerignore | 2 ++ back/Dockerfile | 28 ++++++++++++------ docker-compose.prod.yaml | 62 ++++++++++++++++++++++++++++++++++++++++ front/Dockerfile | 33 ++++++++++++++------- front/nginx-vhost.conf | 14 +++++++++ maps/.dockerignore | 4 +++ messages/.dockerignore | 4 +++ pusher/Dockerfile | 27 +++++++++++------ pusher/Dockerfile.prod | 17 +++++++++++ uploader/Dockerfile | 18 +++++++++--- website/.dockerignore | 5 ++++ 11 files changed, 183 insertions(+), 31 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.prod.yaml create mode 100644 front/nginx-vhost.conf create mode 100644 maps/.dockerignore create mode 100644 messages/.dockerignore create mode 100644 pusher/Dockerfile.prod create mode 100644 website/.dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..f579acb1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +**/node_modules/** +**/Dockerfile diff --git a/back/Dockerfile b/back/Dockerfile index 5ec83a8f..e95145cd 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -1,16 +1,26 @@ -FROM thecodingmachine/workadventure-back-base:latest as builder -WORKDIR /var/www/messages -COPY --chown=docker:docker messages . +# protobuf build +FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 as builder +WORKDIR /usr/src +COPY messages . RUN yarn install && yarn proto -FROM thecodingmachine/nodejs:12 - -COPY --chown=docker:docker back . -COPY --from=builder --chown=docker:docker /var/www/messages/generated /usr/src/app/src/Messages/generated +# typescript build +FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 as builder2 +WORKDIR /usr/src +COPY back/yarn.lock back/package.json ./ RUN yarn install - +COPY back . +COPY --from=builder /usr/src/generated src/Messages/generated ENV NODE_ENV=production RUN yarn run tsc -CMD ["yarn", "run", "runprod"] +# final production image +FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 +WORKDIR /usr/src +COPY back/yarn.lock back/package.json ./ +COPY --from=builder2 /usr/src/dist /usr/src/dist +ENV NODE_ENV=production +RUN yarn install --production +USER node +CMD ["yarn", "run", "runprod"] diff --git a/docker-compose.prod.yaml b/docker-compose.prod.yaml new file mode 100644 index 00000000..1837d06b --- /dev/null +++ b/docker-compose.prod.yaml @@ -0,0 +1,62 @@ +version: "3" +services: + reverse-proxy: + image: traefik:v2.3.7 + command: + - --providers.docker + - --entryPoints.web.address=:80 + - --entryPoints.websecure.address=:443 + ports: + - "80:80" + - "443:443" + depends_on: + - back + - front + volumes: + - /var/run/docker.sock:/var/run/docker.sock + + front: + build: + context: . + dockerfile: front/Dockerfile + args: + BASE_DOMAIN: ${BASE_DOMAIN:-workadventure.localhost} + labels: + - "traefik.http.routers.front.rule=Host(`play.${BASE_DOMAIN:-workadventure.localhost}`)" + - "traefik.http.routers.front.entryPoints=web" + - "traefik.http.services.front.loadbalancer.server.port=8000" + - "traefik.http.routers.front-ssl.rule=Host(`play.${BASE_DOMAIN:-workadventure.localhost}`)" + - "traefik.http.routers.front-ssl.entryPoints=websecure" + - "traefik.http.routers.front-ssl.tls=true" + - "traefik.http.routers.front-ssl.service=front" + + back: + build: + context: . + dockerfile: back/Dockerfile + environment: + SECRET_KEY: yourSecretKey + SECRET_JITSI_KEY: "$SECRET_JITSI_KEY" + ADMIN_API_TOKEN: "$ADMIN_API_TOKEN" + JITSI_URL: $JITSI_URL + JITSI_ISS: $JITSI_ISS + + pusher: + build: + context: . + dockerfile: pusher/Dockerfile + environment: + SECRET_KEY: yourSecretKey + SECRET_JITSI_KEY: "$SECRET_JITSI_KEY" + ADMIN_API_TOKEN: "$ADMIN_API_TOKEN" + API_URL: back:50051 + JITSI_URL: $JITSI_URL + JITSI_ISS: $JITSI_ISS + labels: + - "traefik.http.routers.pusher.rule=Host(`pusher.${BASE_DOMAIN:-workadventure.localhost}`)" + - "traefik.http.routers.pusher.entryPoints=web" + - "traefik.http.services.pusher.loadbalancer.server.port=8080" + - "traefik.http.routers.pusher-ssl.rule=Host(`pusher.${BASE_DOMAIN:-workadventure.localhost}`)" + - "traefik.http.routers.pusher-ssl.entryPoints=websecure" + - "traefik.http.routers.pusher-ssl.tls=true" + - "traefik.http.routers.pusher-ssl.service=pusher" diff --git a/front/Dockerfile b/front/Dockerfile index 6c79ad6e..ab44ea45 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -1,15 +1,28 @@ -FROM thecodingmachine/workadventure-back-base:latest as builder -WORKDIR /var/www/messages -COPY --chown=docker:docker messages . +# protobuf build +FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 as builder +WORKDIR /usr/src +COPY messages . RUN yarn install && yarn proto -# we are rebuilding on each deploy to cope with the API_URL environment URL -FROM thecodingmachine/nodejs:14-apache - -COPY --chown=docker:docker front . -COPY --from=builder --chown=docker:docker /var/www/messages/generated /var/www/html/src/Messages/generated +# webpack build +FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 as builder2 +WORKDIR /usr/src +COPY front/yarn.lock front/package.json ./ RUN yarn install +COPY front . +COPY --from=builder /usr/src/generated src/Messages/generated ENV NODE_ENV=production -ENV STARTUP_COMMAND_1="yarn run build" -ENV APACHE_DOCUMENT_ROOT=dist/ + +ARG BASE_DOMAIN=workadventure.localhost +ARG API_URL=pusher.$BASE_DOMAIN +ARG UPLOADER_URL=uploader.$BASE_DOMAIN +ARG ADMIN_URL=admin.$BASE_DOMAIN + +RUN API_URL=$API_URL UPLOADER_URL=$UPLOADER_URL ADMIN_URL=$ADMIN_URL \ + yarn run build + +# final production image +FROM nginx:1.19.6-alpine@sha256:01747306a7247dbe928db991eab42e4002118bf636dd85b4ffea05dd907e5b66 +COPY front/nginx-vhost.conf /etc/nginx/conf.d/default.conf +COPY --from=builder2 /usr/src/dist /usr/share/nginx/html diff --git a/front/nginx-vhost.conf b/front/nginx-vhost.conf new file mode 100644 index 00000000..81e10f4a --- /dev/null +++ b/front/nginx-vhost.conf @@ -0,0 +1,14 @@ +server { + listen 8000; + listen [::]:8000; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + location ~ ^/[@_]/ { + try_files $uri $uri/ /index.html; + } +} diff --git a/maps/.dockerignore b/maps/.dockerignore new file mode 100644 index 00000000..64d1025d --- /dev/null +++ b/maps/.dockerignore @@ -0,0 +1,4 @@ +/node_modules/ +/dist/bundle.js +/yarn-error.log +/Dockerfile diff --git a/messages/.dockerignore b/messages/.dockerignore new file mode 100644 index 00000000..64d1025d --- /dev/null +++ b/messages/.dockerignore @@ -0,0 +1,4 @@ +/node_modules/ +/dist/bundle.js +/yarn-error.log +/Dockerfile diff --git a/pusher/Dockerfile b/pusher/Dockerfile index 42de3883..4aec9748 100644 --- a/pusher/Dockerfile +++ b/pusher/Dockerfile @@ -1,15 +1,26 @@ -FROM thecodingmachine/workadventure-back-base:latest as builder -WORKDIR /var/www/messages -COPY --chown=docker:docker messages . +# protobuf build +FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 as builder +WORKDIR /usr/src +COPY messages . RUN yarn install && yarn proto -FROM thecodingmachine/nodejs:12 - -COPY --chown=docker:docker pusher . -COPY --from=builder --chown=docker:docker /var/www/messages/generated /usr/src/app/src/Messages/generated +# typescript build +FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 as builder2 +WORKDIR /usr/src +COPY pusher/yarn.lock pusher/package.json ./ RUN yarn install - +COPY pusher . +COPY --from=builder /usr/src/generated src/Messages/generated ENV NODE_ENV=production RUN yarn run tsc +# final production image +FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 +WORKDIR /usr/src +COPY pusher/yarn.lock pusher/package.json ./ +COPY --from=builder2 /usr/src/dist /usr/src/dist +ENV NODE_ENV=production +RUN yarn install --production + +USER node CMD ["yarn", "run", "runprod"] diff --git a/pusher/Dockerfile.prod b/pusher/Dockerfile.prod new file mode 100644 index 00000000..772532f0 --- /dev/null +++ b/pusher/Dockerfile.prod @@ -0,0 +1,17 @@ +FROM node:12.19.0-slim + +RUN mkdir -p /home/node/app && chown -R node:node /home/node/app +WORKDIR /home/node/app + +USER node +ENV NODE_ENV=production +ENV DEBUG=* + +COPY --chown=node:node package.json yarn.lock ./ + +RUN yarn install --prod --frozen-lockfile + +COPY --chown=node:node ./dist/ ./dist/ + +EXPOSE 8080 +CMD ["yarn", "run", "runprod"] diff --git a/uploader/Dockerfile b/uploader/Dockerfile index 3c471f6c..e4366308 100644 --- a/uploader/Dockerfile +++ b/uploader/Dockerfile @@ -1,9 +1,19 @@ -FROM thecodingmachine/nodejs:12 - -COPY --chown=docker:docker uploader . +# typescript build +FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 as builder2 +WORKDIR /usr/src +COPY uploader/yarn.lock uploader/package.json ./ RUN yarn install - +COPY uploader . ENV NODE_ENV=production RUN yarn run tsc +# final production image +FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 +WORKDIR /usr/src +COPY uploader/yarn.lock uploader/package.json ./ +COPY --from=builder2 /usr/src/dist /usr/src/dist +ENV NODE_ENV=production +RUN yarn install --production + +USER node CMD ["yarn", "run", "runprod"] diff --git a/website/.dockerignore b/website/.dockerignore new file mode 100644 index 00000000..576c21a2 --- /dev/null +++ b/website/.dockerignore @@ -0,0 +1,5 @@ +/dist/ +/node_modules/ +/dist/bundle.js +/yarn-error.log +/Dockerfile From 274f5eba4c3d07ea21b9908aeb3b5a4067d70fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 2 Feb 2021 11:19:24 +0100 Subject: [PATCH 02/16] Reworking docker-compose.prod.yaml to make it generic while still having a front container configurable --- .env.prod.template | 17 ++++ back/src/Enum/EnvironmentVariable.ts | 2 - docker-compose.prod.yaml | 91 ++++++++++++------- front/Dockerfile | 35 +++---- .../dist/{index.html.tmpl => index.tmpl.html} | 0 front/templater.sh | 6 +- front/webpack.config.js | 11 ++- 7 files changed, 101 insertions(+), 61 deletions(-) create mode 100644 .env.prod.template rename front/dist/{index.html.tmpl => index.tmpl.html} (100%) diff --git a/.env.prod.template b/.env.prod.template new file mode 100644 index 00000000..184daf3c --- /dev/null +++ b/.env.prod.template @@ -0,0 +1,17 @@ +# The base domain +DOMAIN=workadventure.localhost + +DEBUG_MODE=false +JITSI_URL=meet.jit.si +# If your Jitsi environment has authentication set up, you MUST set JITSI_PRIVATE_MODE to "true" and you MUST pass a SECRET_JITSI_KEY to generate the JWT secret +JITSI_PRIVATE_MODE=false +JITSI_ISS= +SECRET_JITSI_KEY= + +# URL of the TURN server (needed to "punch a hole" through some networks for P2P connections) +TURN_SERVER= +TURN_USER= +TURN_PASSWORD= + +# The URL used by default, in the form: "/_/global/map/url.json" +START_ROOM_URL=/_/global/maps.workadventu.re/Floor0/floor0.json diff --git a/back/src/Enum/EnvironmentVariable.ts b/back/src/Enum/EnvironmentVariable.ts index 2cbfbf2e..95a705fa 100644 --- a/back/src/Enum/EnvironmentVariable.ts +++ b/back/src/Enum/EnvironmentVariable.ts @@ -1,4 +1,3 @@ -const SECRET_KEY = process.env.SECRET_KEY || "THECODINGMACHINE_SECRET_KEY"; const MINIMUM_DISTANCE = process.env.MINIMUM_DISTANCE ? Number(process.env.MINIMUM_DISTANCE) : 64; const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) : 48; const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false; @@ -14,7 +13,6 @@ const GRPC_PORT = parseInt(process.env.GRPC_PORT || '50051') || 50051; export const SOCKET_IDLE_TIMER = parseInt(process.env.SOCKET_IDLE_TIMER as string) || 30; // maximum time (in second) without activity before a socket is closed export { - SECRET_KEY, MINIMUM_DISTANCE, ADMIN_API_URL, ADMIN_API_TOKEN, diff --git a/docker-compose.prod.yaml b/docker-compose.prod.yaml index 1837d06b..e25b07d5 100644 --- a/docker-compose.prod.yaml +++ b/docker-compose.prod.yaml @@ -1,62 +1,91 @@ -version: "3" +version: "3.3" services: reverse-proxy: - image: traefik:v2.3.7 + image: traefik:v2.3 command: + - --log.level=WARN + #- --api.insecure=true - --providers.docker - --entryPoints.web.address=:80 + - --entrypoints.web.http.redirections.entryPoint.to=websecure + - --entrypoints.web.http.redirections.entryPoint.scheme=https - --entryPoints.websecure.address=:443 + - --certificatesresolvers.myresolver.acme.email=d.negrier@thecodingmachine.com + - --certificatesresolvers.myresolver.acme.storage=/acme.json + # used during the challenge + - --certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web ports: - "80:80" - "443:443" + # The Web UI (enabled by --api.insecure=true) + #- "8080:8080" depends_on: - - back + - pusher - front volumes: - /var/run/docker.sock:/var/run/docker.sock + - ./acme.json:/acme.json + restart: unless-stopped + front: - build: - context: . - dockerfile: front/Dockerfile - args: - BASE_DOMAIN: ${BASE_DOMAIN:-workadventure.localhost} + image: thecodingmachine/workadventure-front:master + environment: + DEBUG_MODE: "$DEBUG_MODE" + JITSI_URL: $JITSI_URL + JITSI_PRIVATE_MODE: "$JITSI_PRIVATE_MODE" + API_URL: pusher.${DOMAIN} + TURN_SERVER: "${TURN_SERVER}" + TURN_USER: "${TURN_USER}" + TURN_PASSWORD: "${TURN_PASSWORD}" + START_ROOM_URL: "${START_ROOM_URL}" labels: - - "traefik.http.routers.front.rule=Host(`play.${BASE_DOMAIN:-workadventure.localhost}`)" - - "traefik.http.routers.front.entryPoints=web" - - "traefik.http.services.front.loadbalancer.server.port=8000" - - "traefik.http.routers.front-ssl.rule=Host(`play.${BASE_DOMAIN:-workadventure.localhost}`)" + - "traefik.http.routers.front.rule=Host(`play.${DOMAIN}`)" + - "traefik.http.routers.front.entryPoints=web,traefik" + - "traefik.http.services.front.loadbalancer.server.port=80" + - "traefik.http.routers.front-ssl.rule=Host(`play.${DOMAIN}`)" - "traefik.http.routers.front-ssl.entryPoints=websecure" - "traefik.http.routers.front-ssl.tls=true" - "traefik.http.routers.front-ssl.service=front" - - back: - build: - context: . - dockerfile: back/Dockerfile - environment: - SECRET_KEY: yourSecretKey - SECRET_JITSI_KEY: "$SECRET_JITSI_KEY" - ADMIN_API_TOKEN: "$ADMIN_API_TOKEN" - JITSI_URL: $JITSI_URL - JITSI_ISS: $JITSI_ISS + - "traefik.http.routers.front-ssl.tls.certresolver=myresolver" + restart: unless-stopped pusher: - build: - context: . - dockerfile: pusher/Dockerfile + image: thecodingmachine/workadventure-pusher:master + command: yarn run runprod environment: - SECRET_KEY: yourSecretKey SECRET_JITSI_KEY: "$SECRET_JITSI_KEY" - ADMIN_API_TOKEN: "$ADMIN_API_TOKEN" + SECRET_KEY: yourSecretKey API_URL: back:50051 JITSI_URL: $JITSI_URL JITSI_ISS: $JITSI_ISS labels: - - "traefik.http.routers.pusher.rule=Host(`pusher.${BASE_DOMAIN:-workadventure.localhost}`)" - - "traefik.http.routers.pusher.entryPoints=web" + - "traefik.http.routers.pusher.rule=Host(`pusher.${DOMAIN}`)" + - "traefik.http.routers.pusher.entryPoints=web,traefik" - "traefik.http.services.pusher.loadbalancer.server.port=8080" - - "traefik.http.routers.pusher-ssl.rule=Host(`pusher.${BASE_DOMAIN:-workadventure.localhost}`)" + - "traefik.http.routers.pusher-ssl.rule=Host(`pusher.${DOMAIN}`)" - "traefik.http.routers.pusher-ssl.entryPoints=websecure" - "traefik.http.routers.pusher-ssl.tls=true" - "traefik.http.routers.pusher-ssl.service=pusher" + - "traefik.http.routers.pusher-ssl.tls.certresolver=myresolver" + restart: unless-stopped + + back: + image: thecodingmachine/workadventure-back:master + command: yarn run runprod + environment: + SECRET_JITSI_KEY: "$SECRET_JITSI_KEY" + ADMIN_API_TOKEN: "$ADMIN_API_TOKEN" + ADMIN_API_URL: "$ADMIN_API_URL" + JITSI_URL: $JITSI_URL + JITSI_ISS: $JITSI_ISS + labels: + - "traefik.http.routers.back.rule=Host(`api.${DOMAIN}`)" + - "traefik.http.routers.back.entryPoints=web" + - "traefik.http.services.back.loadbalancer.server.port=8080" + - "traefik.http.routers.back-ssl.rule=Host(`api.${DOMAIN}`)" + - "traefik.http.routers.back-ssl.entryPoints=websecure" + - "traefik.http.routers.back-ssl.tls=true" + - "traefik.http.routers.back-ssl.service=back" + - "traefik.http.routers.back-ssl.tls.certresolver=myresolver" + restart: unless-stopped diff --git a/front/Dockerfile b/front/Dockerfile index 573eeca2..b0d17877 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -1,29 +1,16 @@ -# protobuf build -FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 as builder -WORKDIR /usr/src -COPY messages . +FROM thecodingmachine/workadventure-back-base:latest as builder +WORKDIR /var/www/messages +COPY --chown=docker:docker messages . RUN yarn install && yarn proto -# webpack build -FROM node:14.15.4-buster-slim@sha256:cbae886186467bbfd274b82a234a1cdfbbd31201c2a6ee63a6893eefcf3c6e76 as builder2 -WORKDIR /usr/src -COPY front/yarn.lock front/package.json ./ +# we are rebuilding on each deploy to cope with the API_URL environment URL +FROM thecodingmachine/nodejs:14-apache + +COPY --chown=docker:docker front . +COPY --from=builder --chown=docker:docker /var/www/messages/generated /var/www/html/src/Messages/generated RUN yarn install -COPY front . -COPY --from=builder /usr/src/generated src/Messages/generated ENV NODE_ENV=production - -ARG BASE_DOMAIN=workadventure.localhost -ARG API_URL=pusher.$BASE_DOMAIN -ARG UPLOADER_URL=uploader.$BASE_DOMAIN -ARG ADMIN_URL=admin.$BASE_DOMAIN - -RUN API_URL=$API_URL UPLOADER_URL=$UPLOADER_URL ADMIN_URL=$ADMIN_URL \ - yarn run build - -# final production image -FROM nginx:1.19.6-alpine@sha256:01747306a7247dbe928db991eab42e4002118bf636dd85b4ffea05dd907e5b66 -COPY front/nginx-vhost.conf /etc/nginx/conf.d/default.conf -COPY front/templater.sh /docker-entrypoint.d/templater.sh -COPY --from=builder2 /usr/src/dist /usr/share/nginx/html +ENV STARTUP_COMMAND_0="./templater.sh" +ENV STARTUP_COMMAND_1="yarn run build" +ENV APACHE_DOCUMENT_ROOT=dist/ diff --git a/front/dist/index.html.tmpl b/front/dist/index.tmpl.html similarity index 100% rename from front/dist/index.html.tmpl rename to front/dist/index.tmpl.html diff --git a/front/templater.sh b/front/templater.sh index ac899bbd..e63617c5 100755 --- a/front/templater.sh +++ b/front/templater.sh @@ -1,15 +1,15 @@ #!/usr/bin/env bash set -x set -o nounset errexit -template_file_index=/usr/share/nginx/html/index.html.tmpl -generated_file_index=/usr/share/nginx/html/index.html +template_file_index=dist/index.html.tmpl +generated_file_index=dist/index.html tmp_trackcodefile=/tmp/trackcode # To inject tracking code, you have two choices: # 1) Template using the provided google analytics # 2) Insert with your own provided code, by overriding the ANALYTICS_CODE_PATH # The ANALYTICS_CODE_PATH is the location of a file inside the container -ANALYTICS_CODE_PATH="${ANALYTICS_CODE_PATH:-/usr/share/nginx/html/ga.html.tmpl}" +ANALYTICS_CODE_PATH="${ANALYTICS_CODE_PATH:-dist/ga.html.tmpl}" if [[ "${INSERT_ANALYTICS:-NO}" == "NO" ]]; then echo "" > "${tmp_trackcodefile}" diff --git a/front/webpack.config.js b/front/webpack.config.js index 3b97081c..e4294650 100644 --- a/front/webpack.config.js +++ b/front/webpack.config.js @@ -39,7 +39,16 @@ module.exports = { plugins: [ new HtmlWebpackPlugin( { - template: './dist/index.html' + template: './dist/index.tmpl.html', + minify: { + collapseWhitespace: true, + keepClosingSlash: true, + removeComments: false, + removeRedundantAttributes: true, + removeScriptTypeAttributes: true, + removeStyleLinkTypeAttributes: true, + useShortDoctype: true + } } ), new webpack.ProvidePlugin({ From cc53023586c4190b4164d96bb5f3bc240ce9f1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 2 Feb 2021 11:34:29 +0100 Subject: [PATCH 03/16] Using locally built images --- docker-compose.prod.yaml | 15 ++++++++++++--- front/templater.sh | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docker-compose.prod.yaml b/docker-compose.prod.yaml index e25b07d5..33b4f4df 100644 --- a/docker-compose.prod.yaml +++ b/docker-compose.prod.yaml @@ -29,7 +29,10 @@ services: front: - image: thecodingmachine/workadventure-front:master + build: + context: . + dockerfile: front/Dockerfile + #image: thecodingmachine/workadventure-front:master environment: DEBUG_MODE: "$DEBUG_MODE" JITSI_URL: $JITSI_URL @@ -51,7 +54,10 @@ services: restart: unless-stopped pusher: - image: thecodingmachine/workadventure-pusher:master + build: + context: . + dockerfile: pusher/Dockerfile + #image: thecodingmachine/workadventure-pusher:master command: yarn run runprod environment: SECRET_JITSI_KEY: "$SECRET_JITSI_KEY" @@ -71,7 +77,10 @@ services: restart: unless-stopped back: - image: thecodingmachine/workadventure-back:master + build: + context: . + dockerfile: back/Dockerfile + #image: thecodingmachine/workadventure-back:master command: yarn run runprod environment: SECRET_JITSI_KEY: "$SECRET_JITSI_KEY" diff --git a/front/templater.sh b/front/templater.sh index e63617c5..1851cdc5 100755 --- a/front/templater.sh +++ b/front/templater.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -x set -o nounset errexit -template_file_index=dist/index.html.tmpl +template_file_index=dist/index.tmpl.html generated_file_index=dist/index.html tmp_trackcodefile=/tmp/trackcode From 4efa30847322b7ebde80cf0741b0b9b6949154f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 3 Feb 2021 12:29:41 +0100 Subject: [PATCH 04/16] Moving docker-compose prod file to contrib/docker --- .env.prod.template => contrib/docker/.env.prod.template | 3 +++ .../docker/docker-compose.prod.yaml | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) rename .env.prod.template => contrib/docker/.env.prod.template (85%) rename docker-compose.prod.yaml => contrib/docker/docker-compose.prod.yaml (98%) diff --git a/.env.prod.template b/contrib/docker/.env.prod.template similarity index 85% rename from .env.prod.template rename to contrib/docker/.env.prod.template index 184daf3c..c0c10181 100644 --- a/.env.prod.template +++ b/contrib/docker/.env.prod.template @@ -15,3 +15,6 @@ TURN_PASSWORD= # The URL used by default, in the form: "/_/global/map/url.json" START_ROOM_URL=/_/global/maps.workadventu.re/Floor0/floor0.json + +# The email address used by Let's encrypt to send renewal warnings (compulsory) +ACME_EMAIL= diff --git a/docker-compose.prod.yaml b/contrib/docker/docker-compose.prod.yaml similarity index 98% rename from docker-compose.prod.yaml rename to contrib/docker/docker-compose.prod.yaml index 33b4f4df..22860748 100644 --- a/docker-compose.prod.yaml +++ b/contrib/docker/docker-compose.prod.yaml @@ -30,7 +30,7 @@ services: front: build: - context: . + context: ../.. dockerfile: front/Dockerfile #image: thecodingmachine/workadventure-front:master environment: @@ -55,7 +55,7 @@ services: pusher: build: - context: . + context: ../.. dockerfile: pusher/Dockerfile #image: thecodingmachine/workadventure-pusher:master command: yarn run runprod @@ -78,7 +78,7 @@ services: back: build: - context: . + context: ../.. dockerfile: back/Dockerfile #image: thecodingmachine/workadventure-back:master command: yarn run runprod From 246174c3655432925ce0aa9b615b8b24216b4084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 3 Feb 2021 12:29:56 +0100 Subject: [PATCH 05/16] Removing useless file --- front/nginx-vhost.conf | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 front/nginx-vhost.conf diff --git a/front/nginx-vhost.conf b/front/nginx-vhost.conf deleted file mode 100644 index 81e10f4a..00000000 --- a/front/nginx-vhost.conf +++ /dev/null @@ -1,14 +0,0 @@ -server { - listen 8000; - listen [::]:8000; - server_name localhost; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - } - - location ~ ^/[@_]/ { - try_files $uri $uri/ /index.html; - } -} From 0c892e0243958fd1e8ff34f2289174fd4d328282 Mon Sep 17 00:00:00 2001 From: kharhamel Date: Tue, 2 Feb 2021 18:19:51 +0100 Subject: [PATCH 06/16] FEATURE: implemented a client side blacklist --- front/dist/resources/html/gameReport.html | 56 +++++---- front/dist/resources/html/gameShare.html | 3 - front/dist/resources/logos/blockSign.svg | 22 ++++ front/dist/resources/logos/blockingIcon.png | Bin 0 -> 113739 bytes front/dist/resources/logos/cancel.png | Bin 0 -> 81527 bytes front/dist/resources/style/style.css | 16 ++- front/package.json | 1 + front/src/Connexion/RoomConnection.ts | 3 +- front/src/Phaser/Entity/RemotePlayer.ts | 6 +- front/src/Phaser/Menu/MenuScene.ts | 103 +++-------------- front/src/Phaser/Menu/ReportMenu.ts | 119 ++++++++++++++++++++ front/src/WebRtc/BlackListManager.ts | 24 ++++ front/src/WebRtc/MediaManager.ts | 60 +++++----- front/src/WebRtc/SimplePeer.ts | 16 ++- front/src/WebRtc/VideoPeer.ts | 93 +++++++++------ front/yarn.lock | 2 +- 16 files changed, 338 insertions(+), 186 deletions(-) create mode 100644 front/dist/resources/logos/blockSign.svg create mode 100644 front/dist/resources/logos/blockingIcon.png create mode 100644 front/dist/resources/logos/cancel.png create mode 100644 front/src/Phaser/Menu/ReportMenu.ts create mode 100644 front/src/WebRtc/BlackListManager.ts diff --git a/front/dist/resources/html/gameReport.html b/front/dist/resources/html/gameReport.html index 9a761c32..59ca3592 100644 --- a/front/dist/resources/html/gameReport.html +++ b/front/dist/resources/html/gameReport.html @@ -12,10 +12,6 @@ border-radius: 6px; margin: 2px auto 0; width: 298px; - height: 220px; - } - #gameReport .cautiousText { - font-size: 50%; } #gameReport h1 { background-image: linear-gradient(top, #f1f3f3, #d4dae0); @@ -30,6 +26,9 @@ text-align: center; text-shadow: 0 -1px 0 rgba(0,0,0,0.2), 0 1px 0 #fff; } + #gameReport h3 { + margin: 0; + } #gameReport textarea { font-size: 70%; background: linear-gradient(top, #d6d7d7, #dee0e0); @@ -51,15 +50,17 @@ } #gameReport button { margin-top: 10px; - background-color: black; + font-size: 60%; + background-color: #dc3545; color: white; border-radius: 7px; - padding-bottom: 4px; - width: 60px; + padding: 3px 10px 3px 10px; } #gameReport button#gameReportFormCancel { background-color: #c7c7c700; color: #292929; + display: block; + float: right; } #gameReport section a{ text-align: center; @@ -74,8 +75,11 @@ #gameReport section.text-center{ text-align: center; } - #gameReport section p{ + #gameReport p{ font-size: 8px; + margin: 3px 0 0 0; + } + #gameReport form p{ margin: 0px 70px; } #gameReport section p.err{ @@ -87,18 +91,32 @@ } -