A Dojo Docker image to develop Golang projects. Based on an official Golang image.
- Install Dojo
- Provide a Dojofile
DOJO_DOCKER_IMAGE="kudulab/golang-dojo:2.0.0"
Try to use one of the latest versions of the image as listed under releases.
For experimentation purposes, you may want to create the Dojofile in the test project directory: test/integration/test_dojo_work/executable-no-dependencies
. This provides you some initial golang files to experiment with.
- Run
dojo
while being in the same directory as the Dojofile. It will:
- docker pull a Docker image
- start a Docker container
- log you into the Docker container
- Example commands to run
/dojo/work$ go version
/dojo/work$ go build -o bin/main
/dojo/work$ ./bin/main
Hello, world.
By convention, Dojo docker containers mount the current directory from host to a docker container under /dojo/work
. This convention is followed here. Therefore, if your project is put under /home/me/myproject
, then you should:
- create a file
/home/me/myproject/Dojofile
- change your current directory to
/home/me/myproject
- invoke
dojo
The GOPATH variable is set to /home/dojo/go
in the Docker container. Therefore, by default, after running go install
, the binaries will be put under /home/dojo/go/bin
. You may want to mount this directory from your Docker host or you may want to run go build -o bin/main
instead. The latter option allows to choose the binaries directory.
No symlinks are used.
Golang has particular workspace conventions:
- https://golang.org/doc/code.html#Workspaces
- https://go.dev/doc/gopath_code
- https://github.com/golang/go/wiki/GOPATH
- https://github.com/golang/go/wiki/GithubCodeLayout
To find the solution that fits you best, you may want to set GOPATH
, GOBIN
, GOMODCACHE
, PATH
to some custom values. Example commands to get you started:
export GOPATH=$HOME/go
go env -w GOPATH=$GOPATH
export GOBIN=${PWD}/bin
go env -w GOBIN=${GOBIN}
export PATH=$PATH:$GOPATH
export PATH=$PATH:$GOBIN
export GOMODCACHE=$PWD/pkg/mod
go env -w GOMODCACHE=$GOMODCACHE
You may also want to experiment with:
Instructions how to update this project.
- Create a new feature branch from the main branch
- Work on your changes in that feature branch. If you want, describe you changes in CHANGELOG.md
- Build your image locally to check that it succeeds:
./tasks build
- Test your image locally:
./tasks itest
. You may need to install the test framework - you can do it following these instructions - You may want to play with the Docker container:
./tasks example
/dojo/work$ go build -o bin/main
/dojo/work$ ./bin/main
Hello, world.
- If you are happy with the results, create a PR from your feature branch to master branch
Copyright 2019-2024 Ava Czechowska, Tom Setkowski
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.