-
Notifications
You must be signed in to change notification settings - Fork 112
/
docker-dev
executable file
·41 lines (34 loc) · 1.01 KB
/
docker-dev
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
#!/usr/bin/env bash
set -euo pipefail
export NICE="nice -14 ionice -c2 -n3"
DOCKER_REPO="hodcroftlab/covariants"
DOCKER_IMAGE_NAME_SAFE="${DOCKER_REPO//\//-}"
DOCKER_CONTAINER_NAME="${DOCKER_IMAGE_NAME_SAFE}-$(date +%s)"
USER="user"
GROUP="group"
DEFAULT_COMMAND="cd web && yarn install && yarn dev"
${NICE} docker build -q \
--file="docker/docker-dev.dockerfile" \
--tag="${DOCKER_REPO}" \
--network=host \
--build-arg="UID=$(id -u)" \
--build-arg="GID=$(id -g)" \
--build-arg="USER=${USER}" \
--build-arg="GROUP=${GROUP}" \
"$(pwd)" >/dev/null
${NICE} docker run -it --rm \
--network=host \
--init \
--name="${DOCKER_CONTAINER_NAME}" \
--hostname="${DOCKER_IMAGE_NAME_SAFE}" \
--user="$(id -u):$(id -g)" \
--volume="$(pwd):/workdir" \
--workdir="/workdir" \
--env="UID=$(id -u)" \
--env="GID=$(id -g)" \
--env="USER=${USER}" \
--env="GROUP=${GROUP}" \
--env="PS1=\${USER}@\${HOST}" \
--ulimit core=0 \
"${DOCKER_REPO}" \
bash -c "set -euo pipefail; ${*:-${DEFAULT_COMMAND}}"