wip: docker and travis
This commit is contained in:
parent
3cbc30fe48
commit
cd9abfcd5b
|
@ -0,0 +1,32 @@
|
|||
# make use of vm's
|
||||
sudo: 'required'
|
||||
|
||||
# have the docker service set up (we'll
|
||||
# update it later)
|
||||
services:
|
||||
- docker
|
||||
|
||||
# prepare the machine before any code
|
||||
# installation scripts
|
||||
before_install:
|
||||
- ./.travis/main.sh
|
||||
|
||||
|
||||
script:
|
||||
- make test
|
||||
- make docker-image
|
||||
|
||||
|
||||
# only execute the following instructions in
|
||||
# the case of a success (failing at this point
|
||||
# won't mark the build as a failure).
|
||||
# To have `DOCKER_USERNAME` and `DOCKER_PASSWORD`
|
||||
# filled you need to either use `travis`' cli
|
||||
# and then `travis set ..` or go to the travis
|
||||
# page of your repository and then change the
|
||||
# environment in the settings panel.
|
||||
after_success:
|
||||
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then
|
||||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD ;
|
||||
make docker-push ;
|
||||
fi
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
|
||||
main() {
|
||||
setup_dependencies
|
||||
update_docker_configuration
|
||||
|
||||
echo "SUCCESS:
|
||||
Done! Finished setting up travis machine.
|
||||
"
|
||||
}
|
||||
|
||||
setup_dependencies() {
|
||||
echo "INFO:
|
||||
Setting up dependencies.
|
||||
"
|
||||
|
||||
sudo apt update -y
|
||||
sudo apt install realpath python python-pip -y
|
||||
sudo apt install --only-upgrade docker-ce -y
|
||||
|
||||
sudo pip install docker-compose || true
|
||||
|
||||
docker info
|
||||
docker-compose --version
|
||||
}
|
||||
|
||||
update_docker_configuration() {
|
||||
echo "INFO:
|
||||
Updating docker configuration
|
||||
"
|
||||
|
||||
echo '{
|
||||
"experimental": true,
|
||||
"storage-driver": "overlay2",
|
||||
"max-concurrent-downloads": 50,
|
||||
"max-concurrent-uploads": 50
|
||||
}' | sudo tee /etc/docker/daemon.json
|
||||
sudo service docker restart
|
||||
}
|
||||
|
||||
main
|
13
Makefile
13
Makefile
|
@ -4,6 +4,7 @@ MODULENAME=github.com/h44z/wg-portal
|
|||
GOFILES:=$(shell go list ./... | grep -v /vendor/)
|
||||
BUILDDIR=dist
|
||||
BINARIES=$(subst cmd/,,$(wildcard cmd/*))
|
||||
IMAGE=h44z/wg-portal
|
||||
|
||||
.PHONY: all test clean phony
|
||||
|
||||
|
@ -15,12 +16,12 @@ build: dep $(addprefix $(BUILDDIR)/,$(BINARIES))
|
|||
dep:
|
||||
$(GOCMD) mod download
|
||||
|
||||
validate:
|
||||
validate: dep
|
||||
$(GOCMD) fmt $(GOFILES)
|
||||
$(GOCMD) vet $(GOFILES)
|
||||
$(GOCMD) test -race $(GOFILES)
|
||||
|
||||
coverage:
|
||||
coverage: dep
|
||||
$(GOCMD) fmt $(GOFILES)
|
||||
$(GOCMD) test $(GOFILES) -v -coverprofile .testCoverage.txt
|
||||
$(GOCMD) tool cover -func=.testCoverage.txt # use total:\s+\(statements\)\s+(\d+.\d+\%) as Gitlab CI regextotal:\s+\(statements\)\s+(\d+.\d+\%)
|
||||
|
@ -28,7 +29,7 @@ coverage:
|
|||
coverage-html: coverage
|
||||
$(GOCMD) tool cover -html=.testCoverage.txt
|
||||
|
||||
test:
|
||||
test: dep
|
||||
$(GOCMD) test $(MODULENAME)/... -v -count=1
|
||||
|
||||
clean:
|
||||
|
@ -36,5 +37,11 @@ clean:
|
|||
rm -rf .testCoverage.txt
|
||||
rm -rf $(BUILDDIR)
|
||||
|
||||
docker-build:
|
||||
docker build -t $(IMAGE) .
|
||||
|
||||
docker-push:
|
||||
docker push $(IMAGE)
|
||||
|
||||
$(BUILDDIR)/%: cmd/%/main.go dep phony
|
||||
$(GOCMD) build -o $@ $<
|
|
@ -0,0 +1,12 @@
|
|||
version: '3.6'
|
||||
services:
|
||||
wg-portal:
|
||||
image: h44z/wg-portal:latest
|
||||
container_name: wg-portal
|
||||
restart: unless-stopped
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
network_mode: "host"
|
||||
volumes:
|
||||
- /etc/wireguard:/etc/wireguard
|
||||
- ./data:/app/data
|
Loading…
Reference in New Issue