Skip to content

Commit

Permalink
Merge pull request #18 from kuzmik/kuzmik/more-goreleaser-again
Browse files Browse the repository at this point in the history
chore: cleanups for goreleaser, still
  • Loading branch information
kuzmik authored Dec 6, 2023
2 parents 8e56641 + 4422833 commit f3791d4
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 71 deletions.
70 changes: 35 additions & 35 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
name: "CodeQL"
# name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '41 22 * * 4'
# on:
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
# schedule:
# - cron: '41 22 * * 4'

jobs:
analyze:
name: Analyze
runs-on: 'ubuntu-latest'
timeout-minutes: 360
permissions:
actions: read
contents: read
security-events: write
# jobs:
# analyze:
# name: Analyze
# runs-on: 'ubuntu-latest'
# timeout-minutes: 360
# permissions:
# actions: read
# contents: read
# security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# strategy:
# fail-fast: false
# matrix:
# language: [ 'go' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# # Initializes the CodeQL tools for scanning.
# - name: Initialize CodeQL
# uses: github/codeql-action/init@v2
# with:
# languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2
# - name: Autobuild
# uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
# - name: Perform CodeQL Analysis
# uses: github/codeql-action/analyze@v2
# with:
# category: "/language:${{matrix.language}}"
9 changes: 4 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Run Tests
name: "Run Tests"

on:
push:
pull_request:

jobs:
Expand All @@ -18,5 +14,8 @@ jobs:
with:
go-version: '1.21.4'

- name: Vet
run: go vet ./...

- name: Test
run: go test -v ./...
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ run: build
@./$(TARGET)

docker: clean lint
@docker build --build-arg="VERSION=${VERSION}" --build-arg="BUILD_TIME=${BUILD_TIME}" --build-arg="BUILD_SHA=${BUILD_SHA}" -f build/Dockerfile . -t proxysql-agent
@docker build --build-arg="VERSION=${VERSION}" --build-arg="BUILD_TIME=${BUILD_TIME}" --build-arg="BUILD_SHA=${BUILD_SHA}" -f build/dev.Dockerfile . -t proxysql-agent
32 changes: 2 additions & 30 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
# syntax=docker/dockerfile:1
FROM alpine:3.18

# Stage 1
FROM golang:1.21.4-alpine AS builder

ARG BUILD_SHA
ARG BUILD_TIME
ARG VERSION

ENV GO111MODULE=on

# Set destination for COPY
WORKDIR /build

COPY go.sum go.mod ./

RUN go mod download

COPY . .

RUN apk update \
&& apk add --no-cache git=2.40.1-r0 \
&& rm -rf /var/cache/apk/* /lib/apk/db/*

RUN CGO_ENABLED="0" go build -ldflags "-s -w -X 'main.version=${VERSION}' -X 'main.build=${BUILD_SHA}' -X 'main.builddate=${BUILD_TIME}'" -o proxysql-agent cmd/proxysql-agent/main.go

# Stage 2
FROM alpine:3.18.4 as runner

# add mysql-client, curl, jq, etc to apk add when we're ready
RUN apk update \
&& apk add --no-cache bash=5.2.15-r5 \
&& rm -rf /var/cache/apk/* \
Expand All @@ -41,4 +13,4 @@ COPY --chown=agent:agent --from=builder --chmod=600 /build/configs/example_confi

USER agent

ENTRYPOINT ["/app/proxysql-agent"]
ENTRYPOINT ["/app/proxysql-agent"]
44 changes: 44 additions & 0 deletions build/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# syntax=docker/dockerfile:1

# Stage 1
FROM golang:1.21.4-alpine AS builder

ARG BUILD_SHA
ARG BUILD_TIME
ARG VERSION

ENV GO111MODULE=on

# Set destination for COPY
WORKDIR /build

COPY go.sum go.mod ./

RUN go mod download

COPY . .

RUN apk update \
&& apk add --no-cache git=2.40.1-r0 \
&& rm -rf /var/cache/apk/* /lib/apk/db/*

RUN CGO_ENABLED="0" go build -ldflags "-s -w -X 'main.version=${VERSION}' -X 'main.build=${BUILD_SHA}' -X 'main.builddate=${BUILD_TIME}'" -o proxysql-agent cmd/proxysql-agent/main.go

# Stage 2
FROM alpine:3.18.4 as runner

# add mysql-client, curl, jq, etc to apk add when we're ready
RUN apk update \
&& apk add --no-cache bash=5.2.15-r5 \
&& rm -rf /var/cache/apk/* \
&& addgroup agent \
&& adduser -S agent -u 1000 -G agent

WORKDIR /app

COPY --chown=agent:agent --from=builder --chmod=700 /build/proxysql-agent /app/
COPY --chown=agent:agent --from=builder --chmod=600 /build/configs/example_config.yaml /app/config.yaml

USER agent

ENTRYPOINT ["/app/proxysql-agent"]

0 comments on commit f3791d4

Please sign in to comment.