From 6a6cf803465cf2c62815a7d8543da10cd1fec50a Mon Sep 17 00:00:00 2001 From: Edi Date: Fri, 12 Jun 2020 14:11:43 +0200 Subject: [PATCH] Optimizing docker build --- .dockerignore | 1 + .gitignore | 5 +++- Dockerfile | 21 +++----------- Dockerfile.dev | 18 ++++++++---- apps/remix-ide/README.md | 37 +++++++++++++++++++++++++ build.yaml | 15 ++++++++++ ci/build_and_publish_docker_images.sh | 8 ++++-- docker-compose.yaml | 6 ++-- nginx.conf | 40 +++++++++++++++++++++++++++ 9 files changed, 123 insertions(+), 28 deletions(-) create mode 100644 .dockerignore create mode 100644 build.yaml create mode 100644 nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..3c3629e647 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/.gitignore b/.gitignore index 71991311a3..5668ec15a0 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,7 @@ testem.log # System Files .DS_Store -Thumbs.db \ No newline at end of file +contracts +TODO +.tern-port +temp_publish_docker diff --git a/Dockerfile b/Dockerfile index 79d8a6a499..7bae0b70ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,6 @@ -FROM node:10 -# Create Remix user, don't use root! -# RUN yes | adduser --disabled-password remix && mkdir /app -# USER remix +FROM nginx:alpine +WORKDIR / -# #Now do remix stuff -# USER remix -WORKDIR /home/remix +COPY ./temp_publish_docker/ /usr/share/nginx/html/ -RUN git clone https://github.com/ethereum/remix-ide.git -RUN git checkout origin remix_live - -WORKDIR /home/remix/remix -RUN npm install -RUN npm run build - -EXPOSE 8080 65520 - -CMD ["npm", "run", "serve"] +EXPOSE 80 diff --git a/Dockerfile.dev b/Dockerfile.dev index b5a988c9a7..f4d6ba5738 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -10,11 +10,19 @@ WORKDIR /home/remix COPY ./ ./ -WORKDIR /home/remix/remix -# npm ci would probably be better -RUN npm install +RUN npm ci RUN npm run build -EXPOSE 8080 65520 +FROM nginx:alpine +WORKDIR / -CMD ["npm", "run", "serve"] +COPY --from=0 /home/remix/build/ /usr/share/nginx/html/build/ +COPY --from=0 /home/remix/index.html /usr/share/nginx/html/index.html +COPY --from=0 /home/remix/nginx.conf /etc/nginx/nginx.conf +COPY --from=0 /home/remix/assets/ /usr/share/nginx/html/assets/ +COPY --from=0 /home/remix/icon.png /usr/share/nginx/html/icon.png +COPY --from=0 /home/remix/background.js /usr/share/nginx/html/background.js +COPY --from=0 /home/remix/soljson.js /usr/share/nginx/html/soljson.js +COPY --from=0 /home/remix/package.json /usr/share/nginx/html/package.json + +EXPOSE 80 diff --git a/apps/remix-ide/README.md b/apps/remix-ide/README.md index f58be23248..4e32391488 100644 --- a/apps/remix-ide/README.md +++ b/apps/remix-ide/README.md @@ -45,6 +45,43 @@ npm run setupremix # only if you plan to link remix and remix-ide repositories npm start ``` +## Docker: + +Prerequisites: +* Docker (https://docs.docker.com/desktop/) +* Docker-compose (https://docs.docker.com/compose/install/) + +### Run with docker + +If you want to run latest changes that are merged into master branch then run: + +``` +docker pull remixproject/remix-ide:latest +docker run -p 8080:80 remixproject-remix-ide:latest +``` + +If you want to run latest remix-live release run. +``` +docker pull remixproject/remix-ide:remix_live +docker run -p 8080:80 remixproject-remix-ide:remix_live +``` + +### Run with docker-compose: + +To run locally without building you only need docker-compose.yaml file and you can run: + +``` +docker-compose pull +docker-compose up -d +``` + +Then go to http://localhost:8080 and you can use you Remix instance. + +To fetch docker-compose file without cloning this repo run: +``` +curl https://raw.githubusercontent.com/ethereum/remix-ide/master/docker-compose.yaml > docker-compose.yaml +``` + ## DEVELOPING: Run `npm start` and open `http://127.0.0.1:4200` in your browser. diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000000..599cbfd8f5 --- /dev/null +++ b/build.yaml @@ -0,0 +1,15 @@ +version: "3.7" +x-project-base: + &project-base + restart: always + networks: + - remixide + +networks: + remixide: + +services: + remixide: + build: + context: . + dockerfile: Dockerfile diff --git a/ci/build_and_publish_docker_images.sh b/ci/build_and_publish_docker_images.sh index a814cd0ebf..c866d2b989 100755 --- a/ci/build_and_publish_docker_images.sh +++ b/ci/build_and_publish_docker_images.sh @@ -1,12 +1,16 @@ #!/bin/bash set -e -# If not staging and master branch are existing export TAG="$CIRCLE_BRANCH" +if [ "$CIRCLE_BRANCH" == "master" ]; then + export TAG="latest"; +fi + +rm -rf temp_publish_docker mkdir temp_publish_docker cp -r $FILES_TO_PACKAGE temp_publish_docker docker login --username $DOCKER_USER --password $DOCKER_PASS -docker-compose build +docker-compose -f docker-compose.yaml -f build.yaml build docker push remixproject/remix-ide:$TAG diff --git a/docker-compose.yaml b/docker-compose.yaml index c9b5759611..f006b53700 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,6 +13,6 @@ services: <<: *project-base image: remixproject/remix-ide:$TAG container_name: remixide-${TAG} - build: - context: . - dockerfile: Dockerfile.dev + ports: + - 8080:80 + - 65520:65520 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000000..05d9c01c52 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,40 @@ +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + keepalive_timeout 300; + gzip_disable "msie6"; + + include /etc/nginx/conf.d/*.conf; + + server { + listen 80 default_server; + listen [::]:80 default_server; + + root /usr/share/nginx/html; + + index index.html index.htm; + + server_name _; + + location / { + try_files $uri $uri/ /index.html; + } + } +}