-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.dock
78 lines (63 loc) · 2.79 KB
/
.dock
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Defines the environment variables, volumes, and ports that are important when
# developing and testing this repository.
# The project is used to define a canonical name for persistent storage
# volumes. This allows different executors for the same build project (which
# have different repos and container names) to point to the same volumes so gems
# can be reused (e.g. voter-verifier-json and voter-verifier-thrift both have
# the same project name "voter-verifier").
project=voter-verifier
dockerfile dock/development_Dockerfile
build_context dock # Directory to use as build context (relative to repo root)
# Whether or not we're running in a CI context
ci() {
[ "${CI:-0}" = 1 ]
}
env_var CI "${CI:-0}"
# Ensure the container runs as the current user, otherwise the files in the git
# repo may have their ownership changed to root
env_var APP_UID $(user_id)
env_var APP_GID $(group_id)
# Allow our local SSH agent to be used within the container and ensure proper configuration for builds
if [ -n "${SSH_AUTH_SOCK+x}" ]; then
volume "${SSH_AUTH_SOCK}:/tmp/ssh-auth-sock"
env_var SSH_AUTH_SOCK /tmp/ssh-auth-sock
fi
# Mount user SSH configuration for deployments
volume "$HOME/.ssh:/home/app/.ssh"
volume "/etc/ssh/ssh_known_hosts:/etc/ssh/ssh_known_hosts:ro"
# Expose Docker Hub credentials if they exist
if [ -d "$HOME/.docker" ]; then
volume "$HOME/.docker:/home/app/.docker"
fi
# Expose project network configurations (e.g. ports and interfaces) to host in
# development environment only (otherwise we may have conflicts if two tests run
# at the same time on a single build worker)
if ! ci; then
# Define services to launch when the project is composed in an extended Dock, multi-project environment.
# Services should be defined within a docker-compose.yml file associated with the project
startup_services "voter-verifier"
if osx; then
# add to isolated network and publish ports of interest to host to workaround
# https://forums.docker.com/t/should-docker-run-net-host-work/14215
# TODO parametrize
publish "9095:9095" # thrift-rpc
publish "3000:3000" # rails-api
else
# share host network interface
run_flags --network host
fi
# Store files that we like to reuse between runs (e.g. gems)
volume "${project}_cache:/home/app/.cache"
# Persist Dock modifications to /var/lib/docker in order to create a local
# cache for Docker objects (e.g. images) when rebuilding Dock container
volume "${container_name}_docker:/var/lib/docker:rw"
else
# Add to isolated network
run_flags --network bridge
# Utilize test variants of services when in CI mode
startup_services "voter-verifier_test"
# Do not provide a 'named' volume to prevent persisting files (e.g. gems) between runs
volume "/home/app/.cache"
fi
default_command dock/start-everything
# vim: filetype=sh