Skip to content

Commit

Permalink
feat(golang): add new container for go v1.20.11
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Nov 29, 2023
1 parent 3b67ae2 commit 55c9864
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,14 @@ updates:
- ci
- priority-low
- maintenance

- package-ecosystem: docker
directory: /golang
reviewers:
- AliMD
schedule:
interval: daily
labels:
- ci
- priority-low
- maintenance
7 changes: 5 additions & 2 deletions .github/workflows/publish-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ jobs:
- name: python
path: python

- name: golang
path: golang

permissions:
contents: read
packages: write
Expand All @@ -92,7 +95,7 @@ jobs:
with:
filters: |
container_folder:
./${{ matrix.path }}/*
./${{ matrix.path }}/**
- name: 🏗 Extract version from dockerfile
if: ${{ steps.file_change.outputs.container_folder != 'false' }}
Expand All @@ -115,7 +118,7 @@ jobs:

- name: 🏗 Cache Docker Layers
if: ${{ steps.file_change.outputs.container_folder != 'false' }}
uses: actions/cache@v3
uses: actions/cache@v3.3.2
with:
path: /tmp/.buildx-cache
key: container/${{ matrix.path }}
Expand Down
1 change: 1 addition & 0 deletions golang/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
19 changes: 19 additions & 0 deletions golang/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM docker.io/library/golang:1.20.11-alpine3.18

ARG BUILD_REV
ARG BUILD_DATE
LABEL org.opencontainers.image.title="alwatr/golang" \
org.opencontainers.image.description="Go (golang) is a general purpose, higher-level, imperative programming language, packaged by Alwatr." \
org.opencontainers.image.base.name="docker.io/library/golang:1.20.11-alpine3.18" \
org.opencontainers.image.version="1.20.11" \
org.opencontainers.image.ref.name="1.20.11" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REV} \
org.opencontainers.image.vendor="Alwatr" \
org.opencontainers.image.source="https://github.com/Alwatr/containers/tree/next/golang" \
org.opencontainers.image.url="https://github.com/Alwatr/containers/tree/next/golang" \
org.opencontainers.image.documentation="https://github.com/Alwatr/containers/tree/next/golang" \
org.opencontainers.image.authors="S. Ali Mihandoost <[email protected]> (https://ali.mihandoost.com), S. Amir Mohammad Najafi <[email protected]> (https://njfamirm.ir/)" \
cloud.alwatr.image.version.full="1.20.11" \
cloud.alwatr.image.version.short="1"
51 changes: 51 additions & 0 deletions golang/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Alwatr Golang Container

Go (golang) is a general purpose, higher-level, imperative programming language, packaged by Alwatr.

## Usage

Check versions from [Alwatr/packages](https://github.com/Alwatr/containers/pkgs/container/golang)

### Install from the command line

```bash
docker pull ghcr.io/alwatr/golang:1.21.4
```

### Use as base image in Dockerfile

```dockerfile
FROM ghcr.io/alwatr/golang:1.21.4

WORKDIR /usr/src/app

# Pre-copy/cache go.mod to pre-download dependencies and only re-download them in subsequent builds if they change.
COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
RUN go build -v -o /usr/local/bin/my-app ./

CMD ["my-app"]
```

### Use as a builder image in a multi-stage Dockerfile

```dockerfile
FROM ghcr.io/alwatr/golang:1.21.4 AS builder

WORKDIR /usr/src/app

# Pre-copy/cache go.mod to pre-download dependencies and only re-download them in subsequent builds if they change.
COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
RUN go build -v -o /usr/local/bin/my-app ./

FROM ghcr.io/alwatr/alpine:3.18

COPY --from=builder /usr/local/bin/my-app /usr/local/bin/my-app

CMD ["my-app"]
```

0 comments on commit 55c9864

Please sign in to comment.