Skip to content

Commit

Permalink
init go version (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
pperzyna authored Sep 5, 2019
1 parent 3ef8a78 commit f9c7fca
Show file tree
Hide file tree
Showing 17 changed files with 1,060 additions and 227 deletions.
76 changes: 76 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
version: 2.1

orbs:
prometheus: prometheus/[email protected]

jobs:
test:
docker:
- image: circleci/golang:1.12

steps:
- prometheus/setup_environment
- run: make style build
- prometheus/store_artifact:
file: locust_exporter

publish_master:
description: Build and publish container images from the master branch.
docker:
- image: circleci/golang:1.12
steps:
- prometheus/setup_build_environment
- prometheus/publish_images:
login_variable: REGISTRY_USER
organization: containersol
password_variable: REGISTRY_PASS
registry: docker.io

publish_release:
description: Build and publish binaries and container images for a given release tag.
docker:
- image: circleci/golang:1.12
steps:
- prometheus/setup_build_environment
- run: promu crossbuild tarballs
- run: promu checksum .tarballs
- run: promu release .tarballs
- store_artifacts:
destination: releases
path: .tarballs
- prometheus/publish_release_images:
login_variable: REGISTRY_USER
organization: containersol
password_variable: REGISTRY_PASS
registry: docker.io

workflows:
version: 2
locust_exporter:
jobs:
- test:
filters:
tags:
only: /.*/
- prometheus/build:
name: build
filters:
tags:
only: /.*/
- publish_master:
requires:
- test
- build
filters:
branches:
only: master
- publish_release:
requires:
- test
- build
filters:
tags:
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
branches:
ignore: /.*/
92 changes: 3 additions & 89 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,89 +1,3 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject
locust_exporter
main
.idea
23 changes: 23 additions & 0 deletions .promu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
verbose: true
go:
version: 1.12
cgo: false
repository:
path: github.com/ContainerSolutions/locust_exporter
build:
flags: -a -tags netgo
ldflags: |
-s
-X {{repoPath}}/version.Version={{.Version}}
-X {{repoPath}}/version.Revision={{.Revision}}
-X {{repoPath}}/version.Branch={{.Branch}}
-X {{repoPath}}/version.BuildUser={{user}}@{{host}}
-X {{repoPath}}/version.BuildDate={{date "20060102-15:04:05"}}
tarball:
prefix: .
files:
- LICENSE
crossbuild:
platforms:
- linux/amd64
- linux/386
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CHANGELOG

## 0.2.0 / 2019-09-06

Initial release of Go version

## 0.1.0 / 2019-09-04

Initial release of Python version
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
FROM python:3-alpine

WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
FROM golang:alpine AS builder
RUN apk update && apk add --no-cache git
WORKDIR $GOPATH/src/ContainerSolutions/locust_exporter/
COPY . .
CMD ["python", "./locust_exporter.py"]
RUN GO111MODULE=on go mod download

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/locust_exporter

FROM scratch
COPY --from=builder /go/bin/locust_exporter /go/bin/locust_exporter
ENTRYPOINT ["/go/bin/locust_exporter"]
Loading

0 comments on commit f9c7fca

Please sign in to comment.