-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): binaries + docker images build update (#804)
* Updating the build logic * fix ci-info update * Adding scratch Dockerfile and renaming the existing one to Dockerfile.alpine
- Loading branch information
Showing
10 changed files
with
171 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/fclairamb/ci-info/main/config-schema.json", | ||
"version_input_git_tag": { | ||
"pattern": "^v?([0-9.]+)$" | ||
}, | ||
"templates": [{ | ||
"input_file": "build.go.tpl", | ||
"output_file": "build.go" | ||
}] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,87 @@ | ||
name: Build docker images | ||
|
||
on: | ||
push: | ||
# branches: | ||
# - "**" | ||
tags: | ||
- "v*.*.*" | ||
# pull_request: | ||
push: | ||
branches: # At least when doing some tests | ||
- "**" | ||
tags: | ||
- "v*.*.*" | ||
# pull_request: | ||
|
||
jobs: | ||
multi-registries: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Docker meta | ||
id: docker_meta | ||
uses: crazy-max/ghaction-docker-meta@v4 | ||
with: | ||
images: fclairamb/ftpserver | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to DockerHub | ||
if: github.repository == 'fclairamb/ftpserver' | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Login to GitHub Container Registry | ||
if: github.repository == 'fclairamb/ftpserver' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.CR_PAT }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64 | ||
push: ${{ github.repository == 'fclairamb/ftpserver' }} | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
labels: ${{ steps.docker_meta.outputs.labels }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
build-and-push: | ||
strategy: | ||
matrix: | ||
type: ["", "alpine"] | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
- name: Change version | ||
run: | | ||
curl -L https://github.com/fclairamb/ci-info/releases/download/v0.4.4/ci-info_0.4.4_linux_amd64.tar.gz | tar -zx | ||
./ci-info | ||
- name: Docker meta | ||
id: docker_meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
fclairamb/ftpserver | ||
ghcr.io/fclairamb/ftpserver | ||
flavor: | | ||
suffix=${{ matrix.type != '' && format('-{0}', matrix.type) || '' }} | ||
latest=false | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=semver,suffix=,pattern=${{ matrix.type != '' && matrix.type || 'latest' }} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ matrix.type }}-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to DockerHub | ||
if: github.repository == 'fclairamb/ftpserver' | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Login to GitHub Container Registry | ||
if: github.repository == 'fclairamb/ftpserver' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.CR_PAT }} | ||
- name: Build and push (scratch) | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./Dockerfile${{ matrix.type != '' && format('.{0}', matrix.type) || '' }} | ||
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 | ||
push: ${{ github.repository == 'fclairamb/ftpserver' }} | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
labels: ${{ steps.docker_meta.outputs.labels }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
|
||
build-and-push-status: | ||
needs: build-and-push | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- run: echo 'All good' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@v3 | ||
- | ||
name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v3 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
.DS_Store | ||
ftpserver | ||
.idea | ||
.vscode | ||
*.json | ||
ci-info | ||
.idea/ | ||
.vscode/ | ||
*.pem | ||
ftpserver.json | ||
gdrive_token_gdrive.json | ||
__debug__bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
builds: | ||
- ldflags: | ||
- -s -w -X main.BuildVersion={{.Version}} -X main.Commit={{.Commit}} -X main.BuildDate={{.Date}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Should be started with: | ||
# docker run -ti -p 2121-2130:2121-2130 fclairamb/ftpserver | ||
|
||
# Preparing the build environment | ||
FROM golang:1.19-alpine AS builder | ||
ENV GOFLAGS="-mod=readonly" | ||
RUN apk add --update --no-cache bash ca-certificates curl git | ||
RUN mkdir -p /workspace | ||
WORKDIR /workspace | ||
|
||
# Building | ||
COPY . . | ||
RUN CGO_ENABLED=0 go build -mod=readonly -ldflags='-w -s' -v -o ftpserver | ||
|
||
# Preparing the final image | ||
FROM scratch | ||
WORKDIR /app | ||
EXPOSE 2121-2130 | ||
COPY --from=builder /workspace/ftpserver /bin/ftpserver | ||
ENTRYPOINT [ "/bin/ftpserver" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
var ( | ||
// BuildVersion is the current version of the program | ||
BuildVersion = "" | ||
|
||
// BuildDate is the time the program was built | ||
BuildDate = "" | ||
|
||
// Commit is the git hash of the program | ||
Commit = "" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
var ( | ||
// BuildVersion is the current version of the program | ||
BuildVersion = "{{ .Version }}" | ||
|
||
// BuildDate is the time the program was built | ||
BuildDate = "{{ .BuildDate }}" | ||
|
||
// Commit is the git hash of the program | ||
Commit = "{{ .GitCommitHashShort }}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters