├── README.md ├── Dockerfile └── .github └── workflows └── main.yaml /README.md: -------------------------------------------------------------------------------- 1 | # Ubuntu for go 2 | 3 | To build this image run this command and replace with the go version: 4 | 5 | ```shell 6 | docker build --build-arg GO_VERSION= -t ubuntu-go . 7 | ``` -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | 3 | ARG GO_VERSION 4 | ENV GO_VERSION=${GO_VERSION} 5 | 6 | RUN apt-get update 7 | RUN apt-get install -y wget git gcc 8 | 9 | RUN wget -P /tmp "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" 10 | 11 | RUN tar -C /usr/local -xzf "/tmp/go${GO_VERSION}.linux-amd64.tar.gz" 12 | RUN rm "/tmp/go${GO_VERSION}.linux-amd64.tar.gz" 13 | 14 | ENV GOPATH /go 15 | ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH 16 | RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" 17 | 18 | WORKDIR $GOPATH 19 | -------------------------------------------------------------------------------- /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: Create and publish a Docker image 2 | 3 | on: 4 | - push 5 | 6 | env: 7 | REGISTRY: ghcr.io 8 | IMAGE_NAME: ${{ github.repository }} 9 | GO_VERSION: 1.19.1 10 | 11 | jobs: 12 | build-and-push-image: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | packages: write 17 | 18 | steps: 19 | - name: Checkout repository 20 | uses: actions/checkout@v2 21 | 22 | - name: Log in to the Container registry 23 | uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 24 | with: 25 | registry: ${{ env.REGISTRY }} 26 | username: ${{ github.actor }} 27 | password: ${{ secrets.GITHUB_TOKEN }} 28 | 29 | - name: Extract metadata (tags, labels) for Docker 30 | id: meta 31 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 32 | with: 33 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 34 | tags: | 35 | type=raw,value={{branch}}-go${{ env.GO_VERSION }} 36 | 37 | - name: Build and push Docker image 38 | uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc 39 | with: 40 | context: . 41 | push: true 42 | tags: ${{ steps.meta.outputs.tags }} 43 | labels: ${{ steps.meta.outputs.labels }} 44 | build-args: GO_VERSION=${{ env.GO_VERSION }} 45 | --------------------------------------------------------------------------------