Merge pull request #8 from alcionai/docker-image
Build environment docker image
This commit is contained in:
commit
32f14df60e
3
.github/workflows/unitTests.yml
vendored
3
.github/workflows/unitTests.yml
vendored
@ -3,6 +3,9 @@ on: [push]
|
||||
jobs:
|
||||
Run-All:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: src
|
||||
steps:
|
||||
- name: Repo Code Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
14
docker/Dockerfile
Normal file
14
docker/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
FROM golang:1.18
|
||||
|
||||
ARG uid=1000
|
||||
ARG gid=1000
|
||||
|
||||
# Dockerfile with static deps that won't be changed. Right now there's no deps
|
||||
# outside of what the go.mod file has to manage. Makes a user in the container
|
||||
# with the same UID and GID as the current user so that the mounted directory
|
||||
# doesn't end up with files with strange permissions.
|
||||
|
||||
RUN groupadd -g "${gid}" build && \
|
||||
useradd -m -u "${uid}" -g "${gid}" build
|
||||
|
||||
USER build:build
|
||||
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
|
||||
9
docker/paths.sh
Normal file
9
docker/paths.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
|
||||
# TODO(ashmrtnz): Needs adjusting based on where source code lands in the repo
|
||||
# and where the scripts land in the repo.
|
||||
REPO_ROOT=$(dirname $(pwd))
|
||||
REPO_CODE="${REPO_ROOT}/src"
|
||||
GOLANG_BASE_REPO_PATH="/go/src/github.com/alcionai"
|
||||
GOLANG_REPO_PATH="${GOLANG_BASE_REPO_PATH}/$(basename $REPO_ROOT)"
|
||||
DEV_TAG="alcionai/dev"
|
||||
16
docker/run_dev.sh
Executable file
16
docker/run_dev.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Runs the dev docker image with the current user and mounts the source code
|
||||
# directory in the container at the proper go path.
|
||||
# NOTE: The container is ephemeral and destroyed after it is exited (but changes
|
||||
# in the repo's code directory will be available to the host).
|
||||
|
||||
source paths.sh
|
||||
|
||||
docker run \
|
||||
--rm \
|
||||
-it \
|
||||
-v "$REPO_CODE":"$GOLANG_REPO_PATH" \
|
||||
-w "$GOLANG_REPO_PATH" \
|
||||
"$DEV_TAG" \
|
||||
/bin/bash
|
||||
3
src/go.mod
Normal file
3
src/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module github.com/alcionai/corso
|
||||
|
||||
go 1.18
|
||||
Loading…
x
Reference in New Issue
Block a user