Skip to content

Commit

Permalink
Merge pull request scaffold-eth#586 from piraces/improve-docker-docs
Browse files Browse the repository at this point in the history
Improve Docker docs and setup.sh script to check for runnning container
  • Loading branch information
codenamejason authored Dec 1, 2021
2 parents 18c7bf3 + 40eb8c2 commit cffa4eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
16 changes: 12 additions & 4 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# 🏄‍♂️ Using Docker

Prerequisite: [Docker](https://docs.docker.com/engine/install/)/)
Prerequisites:
- [Docker](https://docs.docker.com/engine/install/)
- [Git](https://git-scm.com/)
- Bash Shell: available in macOS by default and the vast majority of Linux distros

***Note**: If you are using a Windows environment, you can use [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/) or a Bash emulator like "Git BASH" (which its included in [Git for Windows](https://gitforwindows.org/)). If you use WSL take into account that you should [configure Docker to use the WSL 2 backend](https://docs.docker.com/desktop/windows/wsl/).*


> clone/fork 🏗 scaffold-eth:
```bash
git clone https://github.com/austintgriffith/scaffold-eth.git
git clone https://github.com/scaffold-eth/scaffold-eth.git
```

> [basic] run the script that sets the stack up and that's it (takes some minutes to finish):
Expand All @@ -24,7 +30,8 @@ cd scaffold-eth
> [advanced] running front-end on a different port (eg. 8080):
```bash
docker rm -f SCAFFOLD_ETH
DOCKER_IMAGE=$(docker ps --filter name=SCAFFOLD_ETH -q)
[ -z "$DOCKER_IMAGE" ] || docker rm -f SCAFFOLD_ETH

docker run \
--name SCAFFOLD_ETH \
Expand All @@ -41,7 +48,8 @@ docker run \
> [advanced] running the container in interactive mode (must run each tool manually):
```bash
docker rm -f SCAFFOLD_ETH
DOCKER_IMAGE=$(docker ps --filter name=SCAFFOLD_ETH -q)
[ -z "$DOCKER_IMAGE" ] || docker rm -f SCAFFOLD_ETH

docker run \
--name SCAFFOLD_ETH \
Expand Down
9 changes: 6 additions & 3 deletions docker/setup.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/bin/bash

DOCKER_IMAGE=$(docker ps --filter name=SCAFFOLD_ETH -q)

if [ "$1" = "start" ]; then
# Run Docker container
# to run the frontend on a different port add the "-e PORT=8080" parameter and change "-p 8080:8080" one.
docker restart SCAFFOLD_ETH || docker run \
[ -z "$DOCKER_IMAGE" ] && docker run \
--name SCAFFOLD_ETH \
-v `pwd`:/opt/scaffold-eth \
-w /opt/scaffold-eth \
-p 3000:3000 \
-p 8545:8545 \
-dt node:16
-dt node:16 || docker restart SCAFFOLD_ETH

docker exec -ti SCAFFOLD_ETH bash -c "yarn install"
docker exec -dt SCAFFOLD_ETH bash -c "yarn chain"
Expand All @@ -18,7 +20,8 @@ if [ "$1" = "start" ]; then
docker exec -dt SCAFFOLD_ETH bash -c "yarn start"
else
if [ "$1" = "deploy" ]; then
docker exec -ti SCAFFOLD_ETH bash -c "yarn deploy"
[ -z "$DOCKER_IMAGE" ] && echo "Container does not exist. Run the script with 'start' before runing it with the 'deploy' option." \
|| docker exec -ti SCAFFOLD_ETH bash -c "yarn deploy"
else
echo "Invalid command. Choose 'start' or 'deploy'."
fi
Expand Down

0 comments on commit cffa4eb

Please sign in to comment.