使用Docker部署Scratch3.0

scratch3.0圖標(biāo)

簡(jiǎn)介

Scratch是由MIT(麻省理工學(xué)院)米切爾·瑞斯尼克(Mitch Resnick)教授帶領(lǐng)的“終身幼兒園團(tuán)隊(duì)”(Lifelong Kindergarten Group)開(kāi)發(fā)的一款積木式少兒編程軟件。

通過(guò)類似拖動(dòng)積木塊的方式和使用軟件中的素材,可以很容易地創(chuàng)造有趣的動(dòng)畫、游戲,以及控制機(jī)器人和電子設(shè)備等,在創(chuàng)作的過(guò)程中不僅習(xí)得了Science(科學(xué)), Technology(技術(shù)), Engineering(工程), Arts(藝術(shù)), Maths(數(shù)學(xué))等多個(gè)領(lǐng)域的知識(shí),而且可以培養(yǎng)邏輯思維能力、觀察能力、創(chuàng)新能力和想象力。

想在家里的服務(wù)器部署Scratch3.0環(huán)境給小朋友學(xué)編程,但是pad安裝安卓版本后現(xiàn)實(shí)很小,就想部署服務(wù)器版本通過(guò)瀏覽器操作,因此在ubuntu使用docker部署容器,基于Ubuntu部署Docker環(huán)境可參考基于Ubuntu部署Docker環(huán)境。

整體流程如下:本地下載Scratch3.0源碼->使用node:12.16鏡像進(jìn)行npm編譯->使用apache鏡像發(fā)布;

一、Scratch3.0源碼下載

下載scratch-gui、scratch-blocks、scratch-www、scratch-vm四個(gè)倉(cāng)庫(kù)的代碼到本地,命令如下:

git clone git@github.com:LLK/scratch-gui.git
git clone git@github.com:LLK/scratch-blocks.git
git clone git@github.com:LLK/scratch-www.git
git clone git@github.com:LLK/scratch-vm.git

二、使用node:12.16鏡像進(jìn)行編譯

1、啟動(dòng)容器

使用以下命令進(jìn)入容器shell,node鏡像接近1G,如果下載慢,可以參考ubuntu環(huán)境使用Docker部署服務(wù)配置鏡像加速器,也可以使用node:12.16-alpine3.11鏡像,這個(gè)小一些,按時(shí)alpine不熟悉,因此我還是使用基于debian的node鏡像,同時(shí)將代碼目錄掛載到容器中:

docker run -ti -v ~/work/data/scratch:/scratch node:12.16 bash

2、配置編譯環(huán)境

## 修改鏡像源為阿里云
sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list 
sed -i s@/security.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list
## 更新
apt update 
apt upgrade -y
## 安裝vim
apt install vim 
vim /etc/apt/sources.list

將整個(gè)軟件源替換為阿里源(debian11.x):

deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb http://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main
deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib

然后再更新一次,并安裝必要的依賴包:

## 更新
apt update 
apt upgrade -y
## 安裝依賴包
apt install git  python2 curl openssh-server openssh-client

3、安裝npm依賴包

## 配置阿里源并查看
npm config set registry https://registry.npm.taobao.org/
npm config get registry

npm i -g webpack webpack-cli webpack-dev-server
cd /scratch/scratch-gui/
npm install
BUILD_MODE=dist npm run build

在build目錄下會(huì)生成編譯好的網(wǎng)站文件;

三、使用apache鏡像發(fā)布

## 將編譯生成的buid目錄掛載到apache2的默認(rèn)網(wǎng)站路徑
docker run -d --name apache2-container -e TZ=UTC -p 8181:80 -v ~/work/data/scratch/scratch-gui/build:/var/www/html ubuntu/apache2

四、使用已有Scratch3.0鏡像直接發(fā)布

docker run -d -p 7777:80 xaviblanes/scratch3.0 /bin/bash -c "nohup ping -i 1000 www.baidu.com"
docker exec -it 'container id'
service apache2 start

標(biāo)簽和鏈接

Index: #Linux-Index

Info: #Scratch

參考文獻(xiàn)

使用 Docker 輕松構(gòu)建 Scratch 3.0
CentOS(寶塔)部署安裝發(fā)布Scratch3.0

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容