Skip to content

Commit

Permalink
feat: releases are now static builds
Browse files Browse the repository at this point in the history
  • Loading branch information
thefab committed Jul 10, 2020
1 parent ac3aef2 commit 290aac0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 33 deletions.
45 changes: 34 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
name: build

on:
push:
branches:
- master
pull_request:
branches:
- master
push: {}
pull_request: {}
release:
types:
- published

jobs:
prepare:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
# we block concurrent executions because of concurrency issues
# on docker build image
- name: 'Block Concurrent Executions'
uses: softprops/turnstyle@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
name: checkout repository
# only for push or release
- name: make docker buildimage
uses: elgohr/Publish-Docker-Github-Action@master
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'push'
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
name: metwork/logproxy-centos6-buildimage
context: docker
workdir: docker
cache: true
tags: "latest"
tags: "temporary"
build:
runs-on: ubuntu-latest
needs: prepare
Expand All @@ -34,23 +39,41 @@ jobs:
uses: actions/checkout@v2
- name: debug env
run: env |grep GITHUB
- name: build
uses: docker://metwork/logproxy-centos6-buildimage
- name: compute tag name
id: vars
run: |
TMPREF=${GITHUB_REF#refs/*/}
if [[ "$TMPREF" == */merge ]]; then echo ::set-output name=tag::`echo pr${TMPREF} |awk -F '/' '{print $1;}'`; else echo ::set-output name=tag::${TMPREF}; fi
- name: "Install system deps"
run: |
sudo apt-get update
sudo apt-get -y install valgrind
- name: "Basic build and test"
run: |
make DEBUG=yes
make leak
make clean
make
# only for releases or push
- name: release
uses: docker://metwork/logproxy-centos6-buildimage:temporary
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'push'
# only for releases or push
- name: make tar.gz
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'push'
run: |
mv release log_proxy-linux64-${{ steps.vars.outputs.tag }}
mkdir log_proxy-linux64-${{ steps.vars.outputs.tag }}
cp release/usr/local/bin/* log_proxy-linux64-${{ steps.vars.outputs.tag }}/
tar -cvf log_proxy-linux64-${{ steps.vars.outputs.tag }}.tar log_proxy-linux64-${{ steps.vars.outputs.tag }}
gzip log_proxy-linux64-${{ steps.vars.outputs.tag }}.tar
# only for releases or push
- name: upload artifact
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'push'
uses: actions/upload-artifact@v1
with:
name: log_proxy-linux64-${{ steps.vars.outputs.tag }}
path: ./log_proxy-linux64-${{ steps.vars.outputs.tag }}
# only for releases
- name: upload release asset
id: upload-release-asset
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
26 changes: 11 additions & 15 deletions .metwork-framework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,24 @@ To install the binary distribution:

```
# As root user (or with sudo)
# (example with 0.1.0 release, please fix the number to the release you want to install)
export RELEASE=v0.1.0
cd /opt
wget -O log_proxy-linux64-${RELEASE}.tar.gz "https://github.com/metwork-framework/log_proxy/releases/download/${RELEASE}/log_proxy-linux64-${RELEASE}.tar.gz"
zcat log_proxy-linux64-${RELEASE}.tar.gz |tar xvf -
ln -s log_proxy-linux64-${RELEASE} log_proxy
rm -f log_proxy-linux64-${RELEASE}.tar.gz
bash -c "$(curl -fsSLk https://raw.githubusercontent.com/metwork-framework/log_proxy/master/installer/install.sh)"
```

You can now use it with absolute path `/opt/log_proxy/bin/log_proxy` and `opt/log_proxy/bin/log_proxy_wrapper`.
Notes:

For a more convenient way, configure your `PATH` to prepend the `/opt/log_proxy/bin` path. For example (maybe you would have to adapt this to your specific Linux distribution):
- if you are very concerned about the security of your system and if you don't want to execute
a remote `root` script on your system, please review the [very small](https://raw.githubusercontent.com/metwork-framework/log_proxy/master/installer/install.sh)
install script (it's just about downloading and installing two statically compiled binaries in `/usr/local/bin/`)
- our binary distribution won't work on [Alpine Linux](https://alpinelinux.org/) because of `glibc` replacement but @tomalok is maintaining a [log_proxy Alpine Linux package](https://pkgs.alpinelinux.org/packages?name=log_proxy).

## How to uninstall?

```
cat >/etc/profile.d/log_proxy.sh <<EOF
# Add log_proxy directory to PATH
export PATH="/opt/log_proxy/bin:${PATH}"
EOF
# As root user (or with sudo)
rm -f /usr/local/bin/log_proxy
rm -f /usr/local/bin/log_proxy_wrapper
```

After a restart of your terminal, you should use `log_proxy` directly by its name.

## Why this tool?

### Why not using `logrotate` with `copytruncate` feature?
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: all clean install test leak coverage release

all:
cd src && $(MAKE) all

Expand All @@ -18,7 +20,4 @@ coverage:
cd src && $(MAKE) coverage

release: clean
mkdir -p release/lib
cd src && $(MAKE) PREFIX=$(shell pwd)/release FORCE_RPATH='@ORIGIN/../lib' install
ldd release/bin/log_proxy
cp -f `ldd release/bin/log_proxy |grep libglib |awk -F '=> ' '{print $$2;}' |awk '{print $$1;}'` `ldd release/bin/log_proxy |grep libpcre |awk -F '=> ' '{print $$2;}' |awk '{print $$1;}'` release/lib/
cd src && $(MAKE) STATIC=1 DESTDIR=$(shell pwd)/release install
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM centos:centos6
MAINTAINER Fabien MARTY <[email protected]>

RUN yum -y install gcc make valgrind glib2-devel
RUN yum -y install gcc make valgrind glib2-devel glib2-static glibc-static

ADD entrypoint.sh /entrypoint.sh
CMD /entrypoint.sh
2 changes: 0 additions & 2 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

make
make leak
make release

0 comments on commit 290aac0

Please sign in to comment.