Script file to build a basic dev container image.
* New container will have deps known at the time the container was made
* If deps change a lot, rebuild/save current container image as deps
are outside the directory mount
* Deps are not explicitly listed in the container Dockerfile or script
as go mod is expected to manage them for us
* Automatically creates a container user with UID/GID of the current
user to avoid file ownership issues
This commit is contained in:
parent
6d9d4dc8c7
commit
9522a33ebe
27
docker/build.sh
Executable file
27
docker/build.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Builds a docker image that contains the deps for the current version of the
|
||||
# code. Image expects dev directory to be mounted in the container at runtime.
|
||||
|
||||
source paths.sh
|
||||
|
||||
BASE_TAG="alcionai/base-dev"
|
||||
|
||||
buildImage() {
|
||||
docker build \
|
||||
-f Dockerfile \
|
||||
-t "$BASE_TAG" \
|
||||
--build-arg uid=$(id -u) \
|
||||
--build-arg gid=$(id -g) \
|
||||
.
|
||||
docker run \
|
||||
-v "$REPO_CODE":"$GOLANG_REPO_PATH" \
|
||||
--name build-tmp \
|
||||
-w "$GOLANG_REPO_PATH" \
|
||||
-it \
|
||||
"$BASE_TAG" go get
|
||||
docker commit build-tmp "$DEV_TAG"
|
||||
docker rm build-tmp
|
||||
}
|
||||
|
||||
buildImage
|
||||
Loading…
x
Reference in New Issue
Block a user