Skip to content

Commit

Permalink
Merge branch 'master' into 368-feat-add-a-test-connection-for-notifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephKav committed Mar 26, 2024
2 parents b274bf3 + 036f112 commit 3dca862
Show file tree
Hide file tree
Showing 37 changed files with 2,947 additions and 1,991 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,21 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 20

- name: Build web components
run: make web

- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
cache: true

- name: Check out code into the Go module directory
uses: actions/checkout@master

- name: Get current date
id: date
run: echo "date=$(date -u +"%FT%TZ")" >> $GITHUB_OUTPUT
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Build web components
run: make web

- name: Set outputs
id: vars
run: |
Expand Down Expand Up @@ -81,7 +84,6 @@ jobs:
provenance: false
build-args: |
BUILD_VERSION=${{ github.event.release.tag_name }}
GO_VERSION=${{ env.GO_VERSION }}
- name: Build and push (master)
id: docker_build_master
Expand All @@ -101,4 +103,3 @@ jobs:
provenance: false
build-args: |
BUILD_VERSION=${{ env.sha_short }}
GO_VERSION=${{ env.GO_VERSION }}
9 changes: 9 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 20

- name: Build web components
run: make web

- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
cache: true

- name: Test
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 20

- name: Build web components
run: make web

- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
check-latest: true
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v4
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
# Dependency directories
vendor/

# Output of `go build ./cmd/argus`
# Output of `make build`
/argus

/healthcheck
# React build artifacts
/web/ui/static

# Output of `make build-all`
/.build/
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.requirements.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# go-revive
go install github.com/mgechev/revive@latest
Expand Down
52 changes: 27 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
########
# BASE #
########
ARG DEBIAN_VERSION="bullseye"
ARG DEBIAN_VERSION="bookworm"
ARG GO_VERSION="1.22"
FROM golang:${GO_VERSION}-${DEBIAN_VERSION}
ARG NODE_VERSION="20"
FROM golang:${GO_VERSION}-${DEBIAN_VERSION} as go_builder
FROM node:${NODE_VERSION}-${DEBIAN_VERSION} AS base

COPY --from=go_builder /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"
RUN npm install -g npm@latest

COPY . /build/
WORKDIR /build/

ARG BUILD_VERSION="development"
RUN make BUILD_VERSION=${BUILD_VERSION} go-build
RUN chmod 755 /build/argus

WORKDIR /build/_healthcheck/
RUN go build -o ../healthcheck
RUN chmod 755 /build/healthcheck


#########
# ARGUS #
#########
ARG DEBIAN_VERSION="bullseye"
FROM debian:${DEBIAN_VERSION}-slim
FROM alpine:latest
LABEL maintainer="The Argus Authors <[email protected]>"
RUN \
apt update && \
apt install ca-certificates -y && \
apt autoremove -y && \
apt clean && \
rm -rf \
/tmp/* \
/usr/share/doc/* \
/var/cache/* \
/var/lib/apt/lists/* \
/var/tmp/*
apk update && \
apk add --no-cache \
ca-certificates \
musl-dev \
su-exec && \
rm -rf \
/tmp/* \
/var/cache/*

COPY entrypoint.sh /entrypoint.sh
COPY --from=0 /build/argus /usr/bin/argus
COPY --from=0 /build/healthcheck /healthcheck
COPY --from=0 /build/config.yml.example /app/config.yml
COPY --from=0 /build/LICENSE /LICENSE
COPY --from=base /build/argus /usr/bin/argus
COPY --from=base /build/healthcheck /healthcheck
COPY --from=base /build/config.yml.example /app/config.yml
COPY --from=base /build/LICENSE /LICENSE

RUN \
useradd -u 911 -U -d /app -s /bin/false argus && \
mkdir -p \
/app \
/app/data
addgroup -g 911 -S argus && \
adduser -u 911 -S -D -h /app -s /bin/false argus -G argus && \
mkdir -p \
/app \
/app/data && \
chown -R argus:argus /app
WORKDIR /app

EXPOSE 8080
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ web: web-install web-build
build: web common-build

.PHONY: build-all
build-all: compress-web build-darwin build-freebsd build-linux build-openbsd build-windows
build-all: web-build compress-web build-darwin build-freebsd build-linux build-openbsd build-windows
30 changes: 27 additions & 3 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ GO_ARCHITECTURES_WINDOWS ?= amd64 arm64

GO_VERSION ?= $(shell $(GO) version)
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
GO_BUILD_TAGS ?= "netgo"

PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
Expand Down Expand Up @@ -63,6 +64,13 @@ ifneq (,$(wildcard vendor))
$(GO) mod vendor
endif

.PHONY: update-npm-deps
update-npm-deps:
@echo ">> updating NPM dependencies"
ncu -u && npm install; \
cd web/ui/react-app; \
ncu -u && npm install; \

.PHONY: common-unused
common-unused: $(GOVENDOR)
ifdef GOVENDOR
Expand All @@ -82,16 +90,22 @@ endif

.PHONY: common-build
common-build:
@bash -c "trap 'echo \">> restoring assets\"; scripts/compress_web.sh -d;' EXIT; \
@sh -c "trap 'echo \">> restoring assets\"; scripts/compress_web.sh -d;' EXIT; \
echo '>> compressing assets'; \
scripts/compress_web.sh; \
echo '>> building binaries'; \
CGO_ENABLED=0; \
go build \
-tags="${GO_BUILD_TAGS}" \
-ldflags=\"\
-X 'github.com/release-argus/Argus/util.Version=${BUILD_VERSION}' \
-X 'github.com/release-argus/Argus/util.BuildDate=${BUILD_DATE}'\" \
-o ${OUTPUT_BINARY} \
./cmd/argus/"
./cmd/argus/; \
go build \
-tags="${GO_BUILD_TAGS}" \
-o healthcheck \
./_healthcheck/;"

.PHONY: build-darwin
build-darwin:
Expand All @@ -101,7 +115,9 @@ build-darwin:
$(shell \
GOOS=darwin \
GOARCH=$(GOARCH) \
CGO_ENABLED=0; \
go build \
-tags="${GO_BUILD_TAGS}" \
-ldflags="\
-X 'github.com/release-argus/argus/util.Version=\"${BUILD_VERSION}\"' \
-X 'github.com/release-argus/argus/util.BuildDate=\"${BUILD_DATE}\"'" \
Expand All @@ -119,7 +135,9 @@ build-freebsd:
$(shell \
GOOS=freebsd \
GOARCH=$(GOARCH) \
CGO_ENABLED=0; \
go build \
-tags="${GO_BUILD_TAGS}" \
-ldflags="\
-X 'github.com/release-argus/argus/util.Version=\"${BUILD_VERSION}\"' \
-X 'github.com/release-argus/argus/util.BuildDate=\"${BUILD_DATE}\"'" \
Expand All @@ -137,7 +155,9 @@ build-linux:
$(shell \
GOOS=linux \
GOARCH=$(GOARCH) \
CGO_ENABLED=0; \
go build \
-tags="${GO_BUILD_TAGS}" \
-ldflags="\
-X 'github.com/release-argus/argus/util.Version=\"${BUILD_VERSION}\"' \
-X 'github.com/release-argus/argus/util.BuildDate=\"${BUILD_DATE}\"'" \
Expand All @@ -155,7 +175,9 @@ build-openbsd:
$(shell \
GOOS=openbsd \
GOARCH=$(GOARCH) \
CGO_ENABLED=0; \
go build \
-tags="${GO_BUILD_TAGS}" \
-ldflags="\
-X 'github.com/release-argus/argus/util.Version=\"${BUILD_VERSION}\"' \
-X 'github.com/release-argus/argus/util.BuildDate=\"${BUILD_DATE}\"'" \
Expand All @@ -173,7 +195,9 @@ build-windows:
$(shell \
GOOS=windows \
GOARCH=$(GOARCH) \
CGO_ENABLED=0; \
go build \
-tags="${GO_BUILD_TAGS}" \
-ldflags="\
-X 'github.com/release-argus/argus/util.Version=\"${BUILD_VERSION}\"' \
-X 'github.com/release-argus/argus/util.BuildDate=\"${BUILD_DATE}\"'" \
Expand All @@ -185,7 +209,7 @@ build-windows:

.PHONY: compress-web
compress-web:
@bash "scripts/compress_web.sh"
@sh "scripts/compress_web.sh"

.PHONY: common-docker $(BUILD_DOCKER_ARCHS)
common-docker: $(BUILD_DOCKER_ARCHS)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The backend of Argus is built with [Go](https://go.dev/) and the frontend with [

#### Go changes

To see the changes you've made by modifying any of the `.go` files, you must recompile Argus. You could recompile the whole app with a `make build`, but this will also recompile the React components. To save time (and CPU power), you can use the existing React static and recompile just the Go part by running `make go-build`. (Running this in the root dir will produce the `argus` binary)
To see the changes you've made by modifying any of the `.go` files, you must compile Argus. Run `make build` the first time to ensure the web components are available locally. Amy future builds that don't need the web-ui to be rebuilt can be done with `make go-build` (faster than `make build`). (Running either of these in the root dir will produce an `argus` binary)

#### React changes

Expand Down
2 changes: 1 addition & 1 deletion config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ service:
type: github
url: release-argus/argus
dashboard:
icon: https://github.com/release-argus/Argus/raw/master/web/ui/static/favicon.svg
icon: https://raw.githubusercontent.com/release-argus/Argus/master/web/ui/react-app/public/favicon.svg
icon_link-to: https://release-argus.io
web_url: https://github.com/release-argus/Argus/blob/master/CHANGELOG.md
16 changes: 11 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/sh
set -e

ARGUS_UID=${ARGUS_UID:-911}
ARGUS_GID=${ARGUS_GID:-911}

if [ "$(id -u)" -eq 0 ]; then
echo "Switching user UID:GID to ${ARGUS_UID}:${ARGUS_GID}"
groupmod -o -g "$ARGUS_GID" argus >/dev/null
usermod -o -u "$ARGUS_UID" argus >/dev/null
sed -i -e "s/^\(argus:[^:]\):[0-9]*:[0-9]*:/\1:${ARGUS_UID}:${ARGUS_GID}:/" /etc/passwd
sed -i -e "s/^argus:x:[0-9]\+:argus$/argus:x:${ARGUS_GID}:argus:/" /etc/group

if [ -f "/etc/argus/config.yml" ]; then
echo "---------------------------------------------------------------------"
Expand All @@ -22,10 +23,15 @@ if [ "$(id -u)" -eq 0 ]; then

echo "Applying perms to config.yml and argus.db"
touch /app/data/argus.db
chown argus:argus /app/data/argus.db
chown ${ARGUS_UID}:${ARGUS_GID} \
/app \
/app/data \
/app/data/argus.db \
/app/config.yml

su - argus
echo "Starting..."
su-exec argus /usr/bin/argus "$@"
fi

echo "Starting..."
argus "$@"
exec argus "$@"
11 changes: 5 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module github.com/release-argus/Argus

go 1.22
go 1.22.0

require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/containrrr/shoutrrr v0.8.0
github.com/flosch/pongo2/v5 v5.0.0
github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.1
github.com/prometheus/client_golang v1.18.0
github.com/prometheus/client_golang v1.19.0
github.com/vearutop/statigz v1.4.0
gopkg.in/yaml.v3 v3.0.1
)
Expand All @@ -19,7 +19,7 @@ require (
modernc.org/libc v1.41.0 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/sqlite v1.29.1
modernc.org/sqlite v1.29.5
)

require (
Expand All @@ -32,15 +32,14 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
Expand Down
Loading

0 comments on commit 3dca862

Please sign in to comment.