Skip to content

Commit

Permalink
Docker + deps update (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdouchement authored Jan 18, 2025
1 parent 890ec06 commit 25ae691
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 126 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build docker image
on:
schedule:
- cron: '0 0 */3 * *' # @at 0h0m0s every 3 days
release:
types: [created]
push:
branches: [master]
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags
#
- name: Prepare
id: prep
run: |
if [[ $GITHUB_EVENT_NAME == schedule ]]; then
sudo apt-get update -y
sudo apt-get install -y curl jq
LATEST_TAG=$(curl -sSL https://api.github.com/repos/mdouchement/shigoto/releases/latest | jq -r .tag_name)
git checkout $LATEST_TAG
export GITHUB_REF=refs/tags/$LATEST_TAG
fi
#
#
#
DOCKER_IMAGE=mdouchement/shigoto
VERSION=edge
if [[ $GITHUB_REF == refs/heads/* ]]; then
# Branch name
VERSION=${GITHUB_REF#refs/heads/}
fi
if [[ $GITHUB_REF == refs/tags/v* ]]; then
# Tag name
VERSION=${GITHUB_REF#refs/tags/v}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=tags::${TAGS}
#
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
#
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
#
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
#
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
push: true
tags: ${{ steps.prep.outputs.tags }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
name: Build Release
env:
GO_VERSION: "~1"
TASK_VERSION: v3.11.0
TASK_SUM: 8284fa89367e0bbb8ba5dcb90baa6826b7669c4a317e5b9a46711f7380075e21
TASK_VERSION: v3.41.0
TASK_SUM: 0a2595f7fa3c15a62f8d0c244121a4977018b3bfdec7c1542ac2a8cf079978b8
jobs:
release:
name: Build binaries
Expand Down
53 changes: 53 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# build stage
FROM golang:alpine AS build-env
LABEL maintainer="mdouchement"

RUN apk upgrade
RUN apk add --update --no-cache git curl

ARG CHECKSUM_VERSION=v0.2.4
ARG CHECKSUM_SUM=0540c8446174873f140a8fe8c14d7db46c02d81e1e936b0019fcfa121258e12b

RUN curl -L https://github.com/mdouchement/checksum/releases/download/$CHECKSUM_VERSION/checksum-linux-amd64 -o /usr/local/bin/checksum && \
echo "$CHECKSUM_SUM /usr/local/bin/checksum" | sha256sum -c && \
chmod +x /usr/local/bin/checksum

ARG TASK_VERSION=v3.41.0
ARG TASK_SUM=0a2595f7fa3c15a62f8d0c244121a4977018b3bfdec7c1542ac2a8cf079978b8

RUN curl -LO https://github.com/go-task/task/releases/download/$TASK_VERSION/task_linux_amd64.tar.gz && \
checksum --verify=$TASK_SUM task_linux_amd64.tar.gz && \
tar -xf task_linux_amd64.tar.gz && \
cp task /usr/local/bin/

RUN mkdir -p /go/src/github.com/mdouchement/shigoto
WORKDIR /go/src/github.com/mdouchement/shigoto

ENV CGO_ENABLED=0
ENV GOPROXY=https://proxy.golang.org

COPY . /go/src/github.com/mdouchement/shigoto

RUN go mod download
RUN task build-for-docker

# final stage
FROM alpine
LABEL maintainer="mdouchement"

COPY --from=build-env /go/src/github.com/mdouchement/shigoto/dist/shigoto /usr/local/bin/

RUN mkdir -p /var/run
RUN mkdir -p /etc/shigoto
RUN mkdir -p /etc/shigoto.d # YAML directory

COPY <<EOF /etc/shigoto/shigoto.toml
directory = "/etc/shigoto.d"
socket = "/var/run/shigoto.sock"

[log]
force_color = true
force_formating = true
EOF

CMD ["shigoto", "daemon"]
15 changes: 13 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
version: '3'

vars:
VERSION: 0.4.0
VERSION: 0.4.1
REVISION: { sh: git rev-parse HEAD }

env:
Expand All @@ -17,11 +17,22 @@ tasks:
cmds:
- rm -rf ./dist

build-for-docker:
desc: Build for docker
cmds:
- task: clean
- mkdir -p dist
- task: build
vars:
BINARY_NAME: shigoto
ENTRYPOINT: cmd/shigoto/*.go
TARGET_DIST: ""

build-all:
desc: Build all binaries
cmds:
- task: clean
- mkdir -p ./dist
- mkdir -p dist

- task: build
vars:
Expand Down
64 changes: 34 additions & 30 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,63 +1,67 @@
module github.com/mdouchement/shigoto

go 1.21
go 1.22

toolchain go1.23.1

// https://github.com/Masterminds/sprig/pull/377
replace github.com/imdario/mergo => github.com/darccio/mergo v0.3.11

require (
github.com/Masterminds/sprig/v3 v3.2.3
github.com/d5/tengo/v2 v2.16.1
github.com/Masterminds/sprig/v3 v3.3.0
github.com/d5/tengo/v2 v2.17.0
github.com/gobs/args v0.0.0-20210311043657-b8c0b223be93
github.com/knadh/koanf v1.5.0
github.com/mdouchement/ldt v0.9.1
github.com/mdouchement/logger v0.0.0-20240111140701-71e4ee17e98e
github.com/mdouchement/logger v0.0.0-20240212102128-d36bb9ae9641
github.com/mdouchement/upathex v0.1.0
github.com/pkg/errors v0.9.1
github.com/robfig/cron/v3 v3.0.1
github.com/slok/goresilience v0.2.0
github.com/spf13/cobra v1.8.0
github.com/traefik/yaegi v0.15.1
mvdan.cc/sh/v3 v3.7.0
github.com/spf13/cobra v1.8.1
github.com/traefik/yaegi v0.16.1
mvdan.cc/sh/v3 v3.10.0
)

require (
dario.cat/mergo v1.0.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/semver/v3 v3.3.1 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/direnv/direnv/v2 v2.33.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v1.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/direnv/direnv/v2 v2.35.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.46.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vbauerster/mpb/v8 v8.7.1 // indirect
github.com/vbauerster/mpb/v8 v8.9.1 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
google.golang.org/protobuf v1.36.3 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 25ae691

Please sign in to comment.