This pipeline is running unit tests as a separate step and then builds the docker image.Ĭodefresh.yml version : ' 1.0' stages : - checkout - test - build steps : main_clone : title : Cloning main repository. If your GO application is using GO modules, this is even easier as you don’t need to place the application into a specific GOPATH compliant directory first. If you want to run Go specific steps in your pipeline, you can use freestyle steps with any GO image that you want. # This container exposes port 8080 to the outside world EXPOSE 8080 # Run the executable CMD Run unit tests as part of the pipeline # Download all the dependencies RUN go get -d -v. In the example application, the simple (unoptimized) Dockerfile has an old Go version that still requires GOPATH folders.ĭockerfile FROM golang:1.10 # Set the Current Working Directory inside the container WORKDIR $GOPATH/src//codefresh-contrib/go-sample-app # Copy everything from the current directory to the PWD (Present Working Directory) inside the container COPY. it compiles GO on its own), the pipeline will work as expected. As long as the Dockerfile is self-contained (i.e. The big advantage of this workflow is that the Dockerfile you use can define any Go version and dependency tool. Once you run this pipeline Codefresh will create a Docker image for the Golang application: type : git-clone repo : ' codefresh-contrib/golang-sample-app' revision : master git : github MyAppDockerImage : title : Building Docker Image type : build image_name : my-golang-image working_directory. The most simple pipeline that you can create is just two steps:Ĭodefresh.yml version : ' 1.0' steps : main_clone : title : Cloning main repository. Multi-stage Dockerfile (with Go modules and unit tests).Dockerfile with Go modules (optimized for Docker caching).Simple Dockerfile (with old Go version that requires GOPATH building).The repository contains a simple Golang web application including unit tests. Improve this page on GitHub Create a Docker image for GOĬodefresh can work with Go projects of any version using built-in modules or any other dependency mechanism.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |