deps: migrate to modules (#386)

Move away from using dep to use Go modules which is production ready as
of 1.14.

Also tidy up README to make instructions for local development clearer

Fixes #385
This commit is contained in:
Paul Jolly
2020-04-01 12:47:27 +01:00
committed by GitHub
parent 26a21c080c
commit f1183076e5
7 changed files with 287 additions and 995 deletions

View File

@@ -7,35 +7,50 @@ Under the hood DIND or Docker-in-Docker is used to give the effect of multiple V
A live version is available at: http://play-with-docker.com/
## Requirements
### Requirements
Docker 1.13+ is required.
* [Docker `18.06.0+`](https://docs.docker.com/install/)
* [Go](https://golang.org/dl/) (stable release)
The docker daemon needs to run in swarm mode because PWD uses overlay attachable networks. For that
just run `docker swarm init` in the destination daemon.
### Development
It's also necessary to manually load the IPVS kernel module because as swarms are created in `dind`,
the daemon won't load it automatically. Run the following command for that purpose: `sudo modprobe xt_ipvs`
```bash
# Clone this repo locally
git clone https://github.com/play-with-docker/play-with-docker
cd play-with-docker
# Verify the Docker daemon is running
docker run hello-world
## Development
# Load the IPVS kernel module. Because swarms are created in dind,
# the daemon won't load it automatically
sudo modprobe xt_ipv
Start the Docker daemon on your machine and run `docker pull franela/dind`.
# Ensure Docker daemon is running in swarm mode
docker swarm init
1) Install go 1.7.1+ with `brew` on Mac or through a package manager.
# Get the latest franela/dind image
docker pull franela/dind
2) Install [dep](https://github.com/golang/dep) and run `dep ensure` to pull dependencies
# Optional (with go1.14): pre-fetch module requirements into vendor
# so that no network requests are required within the containers.
# The module cache is retained in the pwd and l2 containers so the
# download is a one-off if you omit this step.
go mod vendor
3) Start PWD as a container with docker-compose up.
# Start PWD as a container
docker-compose up
```
5) Point to http://localhost and click "New Instance"
Now navigate to [http://localhost](http://localhost) and click the green "Start" button
to create a new session, followed by "ADD NEW INSTANCE" to launch a new terminal instance.
Notes:
* There is a hard-coded limit to 5 Docker playgrounds per session. After 4 hours sessions are deleted.
* If you want to override the DIND version or image then set the environmental variable i.e.
`DIND_IMAGE=franela/docker<version>-rc:dind`. Take into account that you can't use standard `dind` images, only [franela](https://hub.docker.com/r/franela/) ones work.
### Port forwarding
In order for port forwarding to work correctly in development you need to make `*.localhost` to resolve to `127.0.0.1`. That way when you try to access to `pwd10-0-0-1-8080.host1.localhost`, then you're forwarded correctly to your local PWD server.