Skip to content

Commit

Permalink
Optimizing docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
edisinovcic authored and yann300 committed Jun 17, 2020
1 parent eaee07a commit 89d2a56
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 27 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ remix
contracts
TODO
.tern-port
temp_publish_docker
21 changes: 4 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
18 changes: 13 additions & 5 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:8080` in your browser.
Expand Down
15 changes: 15 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3.7"
x-project-base:
&project-base
restart: always
networks:
- remixide

networks:
remixide:

services:
remixide:
build:
context: .
dockerfile: Dockerfile
8 changes: 6 additions & 2 deletions ci/build_and_publish_docker_images.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 40 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
}

0 comments on commit 89d2a56

Please sign in to comment.