From d42802528755b23d9e08e233bfeaec74cddc0702 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Fri, 23 Mar 2018 15:49:02 -0400 Subject: [PATCH 1/7] Need protocol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With API_HOST and FALLBACK, need full protocol. API_HOST must be localhost, as it’s the browser performing the local request and does not know the docker network hostnames assigned during docker-compose --- docker-compose.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..8c87e0f07 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: '3.4' +volumes: + npm_data: + runtime_data: + intl_data: + +networks: + scratchapi_scratch_network: + external: true + +services: + app: + container_name: scratch-www-app + hostname: scratch-www-app + environment: + - API_HOST=scratch-api-app + - FALLBACK=scratchr2-app:8080 + build: + context: ./ + dockerfile: Dockerfile + image: scratch-www:latest + command: ./docker_entrypoint.sh npm start + volumes: + - type: bind + source: ./ + target: /var/app/current + volume: + nocopy: true + - type: bind + source: ../scratch-gui + target: /var/app/current/scratch-gui + volume: + nocopy: true + - npm_data:/var/app/current/node_modules + - runtime_data:/runtime + - intl_data:/var/app/current/intl + ports: + - "8333:8333" + networks: + - scratchapi_scratch_network From 878116f949245a9fdef65d32e8548e1da335b7c8 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Fri, 23 Mar 2018 15:49:40 -0400 Subject: [PATCH 2/7] Add protocol and localhost MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With API_HOST and FALLBACK, need full protocol. API_HOST must be localhost, as it’s the browser performing the local request and does not know the docker network hostnames assigned during docker-compose --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8c87e0f07..7f550e83f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,8 +13,8 @@ services: container_name: scratch-www-app hostname: scratch-www-app environment: - - API_HOST=scratch-api-app - - FALLBACK=scratchr2-app:8080 + - API_HOST=http://localhost:8491 + - FALLBACK=http://scratchr2-app:8080 build: context: ./ dockerfile: Dockerfile From 70468321c5ed1737fa7baa979205b088cfa5fce3 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Fri, 23 Mar 2018 15:50:01 -0400 Subject: [PATCH 3/7] Docker files Completes first pass at dockerization --- Dockerfile | 10 ++++++++++ docker_entrypoint.sh | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 Dockerfile create mode 100755 docker_entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..81b021d64 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:6 + +RUN mkdir -p /var/app/current +WORKDIR /var/app/current +COPY . ./ +RUN rm -rf ./node_modules +RUN npm install + +EXPOSE 8333 + diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh new file mode 100755 index 000000000..5e95584c3 --- /dev/null +++ b/docker_entrypoint.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +echo "App Entrypoint" + +if [ ! -f /runtime/.translations ]; then + echo "Generating intl/translations" + make translations + touch /runtime/.translations +fi + +exec "$@" From 5b1891efdbf87e763140cc486347964585487f0a Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Tue, 27 Mar 2018 14:11:24 -0400 Subject: [PATCH 4/7] node:8 is current --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 81b021d64..7ed7e0da3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:6 +FROM node:8 RUN mkdir -p /var/app/current WORKDIR /var/app/current From 89f731efa75c329591c0152162d971719dbea564 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Tue, 27 Mar 2018 15:14:07 -0400 Subject: [PATCH 5/7] Add docker info and documentation --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index d5209408f..f2fcdae8e 100644 --- a/README.md +++ b/README.md @@ -113,5 +113,45 @@ Setting `FALLBACK=https://scratch.mit.edu` allows the web client to retrieve dat Additionally, if you set `FALLBACK=https://scratch.mit.edu`, be aware that clicking on links to parts of the website not yet migrated over (currently such as `Explore`, `Discuss`, `Profile`, etc.) will take you to the Scratch website itself. +#### Docker + +A set of [Docker](https://www.docker.com/what-docker) related files are provided to create isolated [container](https://www.docker.com/what-container) environments suitable for development: + +* Dockerfile +* docker-compose.yml +* docker_entrypoint.sh + +Unless you have access to the Scratch REST API repository, this may not be very useful for you. + +This currently requires a version of the [Scratch GUI](https://github.com/LLK/scratch-gui) repository to be checked out in parallel to scratch-www, e.g.: + +```bash +- + - scratch-www/ + - scratch-gui/ +``` + +##### Docker Quick Start (CLI) + +Make sure you already have the Scratch REST API running locally in its docker environment. + +``` +$ docker-compose up +``` + +After this has launched you will be able to access a running copy of `scratch-www` on port 8333 via `http://localhost:8333` + +##### Docker Configuration + +`Dockerfile` defines how a `scratch-www` docker image is created. + +`docker-compose.yml` takes care of launching `scratch-www` into a development environment that is composed of other components, such as the Scratch REST API server and the legacy Scratch code. If you have not already setup the Scratch REST API in your local environment, you will need to modify `docker-compose.yml` by removing `external: true` from: + +```yaml +networks: + scratchapi_scratch_network: + external: true +``` + #### Windows Some users have experienced difficulties when trying to get our web client to work on Windows. One solution could be to use [Cygwin](https://www.cygwin.com/). If that doesn't work, you might want to use [Wubi](https://wiki.ubuntu.com/WubiGuide) (Windows XP, Vista, 7) or [Wubiuefi](https://github.com/hakuna-m/wubiuefi) (Windows 8 or higher). Wubi(uefi) is a Windows Installer for Ubuntu that allows you to have Ubuntu and Windows on one disk, without the need of an extra partition. From 4c599f1088e498a273f31f1e4cf42b7003cf1f06 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Tue, 5 Jun 2018 10:22:53 -0400 Subject: [PATCH 6/7] Remove outdated reference to parallel scratch-gui --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index f2fcdae8e..b480baecf 100644 --- a/README.md +++ b/README.md @@ -123,14 +123,6 @@ A set of [Docker](https://www.docker.com/what-docker) related files are provided Unless you have access to the Scratch REST API repository, this may not be very useful for you. -This currently requires a version of the [Scratch GUI](https://github.com/LLK/scratch-gui) repository to be checked out in parallel to scratch-www, e.g.: - -```bash -- - - scratch-www/ - - scratch-gui/ -``` - ##### Docker Quick Start (CLI) Make sure you already have the Scratch REST API running locally in its docker environment. From 45f006e04e0af622d410822aa9f299e1614aa717 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Tue, 5 Jun 2018 10:26:48 -0400 Subject: [PATCH 7/7] Emphasize the internal nature of the Docker config --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b480baecf..ff57e1de9 100644 --- a/README.md +++ b/README.md @@ -113,16 +113,19 @@ Setting `FALLBACK=https://scratch.mit.edu` allows the web client to retrieve dat Additionally, if you set `FALLBACK=https://scratch.mit.edu`, be aware that clicking on links to parts of the website not yet migrated over (currently such as `Explore`, `Discuss`, `Profile`, etc.) will take you to the Scratch website itself. +#### Windows +Some users have experienced difficulties when trying to get our web client to work on Windows. One solution could be to use [Cygwin](https://www.cygwin.com/). If that doesn't work, you might want to use [Wubi](https://wiki.ubuntu.com/WubiGuide) (Windows XP, Vista, 7) or [Wubiuefi](https://github.com/hakuna-m/wubiuefi) (Windows 8 or higher). Wubi(uefi) is a Windows Installer for Ubuntu that allows you to have Ubuntu and Windows on one disk, without the need of an extra partition. + #### Docker -A set of [Docker](https://www.docker.com/what-docker) related files are provided to create isolated [container](https://www.docker.com/what-container) environments suitable for development: +_This section is only relevant to the Scratch Team since it requires access to private repositories, so is not usable by 3rd party contributors._ + +A set of [Docker](https://www.docker.com/what-docker) related files are provided to create isolated [container](https://www.docker.com/what-container) environments suitable for end-to-end local development: * Dockerfile * docker-compose.yml * docker_entrypoint.sh -Unless you have access to the Scratch REST API repository, this may not be very useful for you. - ##### Docker Quick Start (CLI) Make sure you already have the Scratch REST API running locally in its docker environment. @@ -144,6 +147,3 @@ networks: scratchapi_scratch_network: external: true ``` - -#### Windows -Some users have experienced difficulties when trying to get our web client to work on Windows. One solution could be to use [Cygwin](https://www.cygwin.com/). If that doesn't work, you might want to use [Wubi](https://wiki.ubuntu.com/WubiGuide) (Windows XP, Vista, 7) or [Wubiuefi](https://github.com/hakuna-m/wubiuefi) (Windows 8 or higher). Wubi(uefi) is a Windows Installer for Ubuntu that allows you to have Ubuntu and Windows on one disk, without the need of an extra partition.