Skip to content

Commit

Permalink
Fix container build (#17)
Browse files Browse the repository at this point in the history
* Tweak release pipeline concurrency

* WIP

* Add tests badge

* make the project work again
  • Loading branch information
alex4108 authored Sep 20, 2022
1 parent ddabc17 commit 03ed776
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FROM qmcgaw/godevcontainer
RUN apk add make --update gcc musl-dev sqlite
RUN go install github.com/go-delve/delve/cmd/dlv@latest
RUN go install github.com/go-delve/delve/cmd/dlv@latest
RUN go install github.com/mattn/go-sqlite3
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"shutdownAction": "stopCompose",
"postCreateCommand": "~/.windows.sh && go mod download && go mod tidy",
"workspaceFolder": "/workspace",
// "overrideCommand": "",
"extensions": [
"golang.go",
"eamodio.gitlens", // IDE Git information
Expand Down
1 change: 0 additions & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ services:
- ~/.kube:/root/.kube:z
environment:
- TZ=
- WORKSPACE_PATH=${PWD}
- CGO_ENABLED=1
cap_add:
# For debugging with dlv
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ on:

permissions: "write-all"

concurrency:
group: "release"
cancel-in-progress: true

jobs:
# build-pages:
# runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -37,6 +39,9 @@ jobs:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: "${{ steps.tag_version.outputs.changelog }}\n\nContainer URI: hub.docker.com/alex4108/approova:${{steps.tag_version.outputs.new_tag}}"
deploy:
runs-on: ubuntu-latest
steps:
- name: Setup Kubectl
uses: Azure/setup-kubectl@v3
- name: Login to Azure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Run golang compilation check
run: make build
run: make test
- name: Build docker image
run: make docker
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ sqlite.db
.vscode/
*/private/*
scripts/local-me.sh
./bin/*
./bin
bin
bin/*
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ RUN apk add sqlite
RUN mkdir -p /app/
RUN mkdir -p /content/
COPY ./bin/approova /app/approova
CMD ["/app/approova"]
RUN chmod +x /app/approova

ENTRYPOINT ["/bin/sh"]
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
PHONY: .build .docker .docker-release
PHONY: .build .docker .docker-release .test

ifndef APPROOVA_TAG
override APPROOVA_TAG = approova
endif

build:
go install github.com/mattn/go-sqlite3
export CGO_ENABLED=1
go build -o ./bin/approova

docker: build
docker build -t $(APPROOVA_TAG) .

docker-release: build
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alex4108/approova:$(APPROOVA_TAG) --push .
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alex4108/approova:$(APPROOVA_TAG) --push .

test: docker
docker run --rm -e CI=true -it $(APPROOVA_TAG)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Approova Discord Bot

[![Test](https://github.com/alex4108/Approova/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/alex4108/Approova/actions/workflows/test.yml)
[![Tests](https://github.com/alex4108/Approova/actions/workflows/test.yml/badge.svg)](https://github.com/alex4108/Approova/actions/workflows/test.yml)
[![Release](https://github.com/alex4108/Approova/actions/workflows/release.yml/badge.svg?branch=master)](https://github.com/alex4108/Approova/actions/workflows/release.yml)
[![GitHub forks](https://img.shields.io/github/forks/alex4108/Approova)](https://github.com/alex4108/Approova/network)
[![GitHub stars](https://img.shields.io/github/stars/alex4108/Approova)](https://github.com/alex4108/Approova/stargazers)
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ func main() {
log.SetReportCaller(true)
log.SetLevel(log.DebugLevel)

InCI, InCIExist := os.LookupEnv("CI")
if InCIExist && InCI == "true" {
log.Fatal("Running in CI. This proves functionality?")
os.Exit(0)
}

Token, tokenExists := os.LookupEnv("APPROOVA_DISCORD_TOKEN")
if !tokenExists {
log.Fatal("APPROOVA_DISCORD_TOKEN is not set. Exiting.")
Expand Down

0 comments on commit 03ed776

Please sign in to comment.