mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 01:57:32 +08:00
Adds a Makefile to make the virtual box creation, start and app run
reproducible. This allows to develop PWD on a container, which is nice and also necessary once "reverse proxy" feature is introduced.
This commit is contained in:
parent
69f9edc695
commit
60395a269a
30
Makefile
Normal file
30
Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
# Prepares the virtual box instance
|
||||
prepare:
|
||||
# Creates the virtual box
|
||||
-docker-machine create -d virtualbox --virtualbox-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v1.13.0-rc1/boot2docker.iso pwd && true
|
||||
# Makes sure the docker daemon has the DinD image pulled
|
||||
-docker-machine ssh pwd "docker pull franela/pwd-1.12.3-experimental-dind"
|
||||
# Daemon should be swarm
|
||||
-docker-machine ssh pwd "docker swarm init --advertise-addr $$(docker-machine ip pwd)"
|
||||
# Stops to daemon to do further configurations on the box
|
||||
-docker-machine stop pwd
|
||||
# Adds the host GOPATH as a shared folder in the box
|
||||
-VBoxManage sharedfolder add pwd --name gopathsrc --hostpath ${GOPATH}src --automount
|
||||
# Do port forwaring so we can reach the app using localhost:3000
|
||||
-VBoxManage modifyvm pwd --natpf1 "nameformapping,tcp,,3000,,3000"
|
||||
|
||||
# Starts the virtual box instance
|
||||
start:
|
||||
# Starts the machine
|
||||
-docker-machine start pwd
|
||||
# Make sure the folder where we'll mount the shared folder exists
|
||||
docker-machine ssh pwd "sudo mkdir -p /go/src"
|
||||
# Mount the host's GOPATH shared folder
|
||||
docker-machine ssh pwd "sudo mount -t vboxsf gopathsrc /go/src"
|
||||
|
||||
# Runs the app
|
||||
run:
|
||||
@eval $$(docker-machine env pwd); \
|
||||
docker-compose up
|
||||
|
||||
.PHONY: prepare start run
|
15
docker-compose.yml
Normal file
15
docker-compose.yml
Normal file
@ -0,0 +1,15 @@
|
||||
version: '2'
|
||||
services:
|
||||
web:
|
||||
# use the latest golang image
|
||||
image: golang
|
||||
# go to the right place and starts the app
|
||||
command: /bin/sh -c 'cd /go/src/github.com/franela/play-with-docker; go run api.go'
|
||||
ports:
|
||||
# app exposes port 3000
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
# since this app creates networks and launches containers, we need to talk to docker daemon
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
# mount the box mounted shared folder to the container
|
||||
- /go/src:/go/src
|
Loading…
x
Reference in New Issue
Block a user