build using Docker
This commit is contained in:
parent
8b1c128a93
commit
b57bdea231
7 changed files with 147 additions and 9 deletions
8
.vimrc
Normal file
8
.vimrc
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
set ts=4 sw=4
|
||||
set ai si
|
||||
|
||||
" can this be copied from the /etc/vim/vimrc file instead?
|
||||
if has("autocmd")
|
||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
endif
|
||||
|
||||
31
.zshrc
Normal file
31
.zshrc
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Lines configured by zsh-newuser-install
|
||||
HISTFILE=~/.histfile
|
||||
HISTSIZE=1000
|
||||
SAVEHIST=1000
|
||||
bindkey -e
|
||||
# End of lines configured by zsh-newuser-install
|
||||
# The following lines were added by compinstall
|
||||
zstyle :compinstall filename '/home/emg/.zshrc'
|
||||
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
# End of lines added by compinstall
|
||||
|
||||
alias l=less m=more
|
||||
alias ll='ls -l'
|
||||
alias vi=vim
|
||||
alias vg='valgrind --leak-check=full --show-leak-kinds=all --gen-suppressions=all'
|
||||
|
||||
ulimit -c unlimited
|
||||
git_prompt() {
|
||||
git branch --color=never |& grep -v "Not a git" | grep '^\*' | head -1 | tr -d '*' | tr ' ' '@'
|
||||
}
|
||||
setopt prompt_subst
|
||||
autoload -U promptinit
|
||||
promptinit
|
||||
PS1='%n@%m:%~$(git_prompt)>'
|
||||
|
||||
RPS1='%T'
|
||||
|
||||
export TZ=CET
|
||||
|
||||
38
Dockerfile
Normal file
38
Dockerfile
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM ubuntu:18.04
|
||||
|
||||
LABEL maintainer="daniel@braxo.se"
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata && \
|
||||
apt-get install -y \
|
||||
cmake \
|
||||
gcc \
|
||||
g++ \
|
||||
git \
|
||||
less \
|
||||
libpcre2-dev \
|
||||
make \
|
||||
valgrind \
|
||||
vim \
|
||||
zsh \
|
||||
&& \
|
||||
apt-get clean
|
||||
|
||||
ADD \
|
||||
.vimrc \
|
||||
.zshrc \
|
||||
/root/
|
||||
|
||||
RUN mkdir /opt/autofw
|
||||
|
||||
WORKDIR /opt/autofw
|
||||
|
||||
ADD src .
|
||||
|
||||
RUN \
|
||||
cmake . && \
|
||||
make
|
||||
|
||||
16
README.md
16
README.md
|
|
@ -13,15 +13,13 @@ It assumes UFW for now.
|
|||
|
||||
## Building
|
||||
|
||||
First install some build tools.
|
||||
On Ubuntu you will run something like this:
|
||||
The easiest way to build this is to use Docker.
|
||||
|
||||
- `apt-get install -y cmake libpcre2-dev make gcc`
|
||||
|
||||
We use CMake.
|
||||
|
||||
- `cmake .`
|
||||
- `make`
|
||||
1. Install the Docker command line client on your machine.
|
||||
1. Run `./build.sh`. This will build a binary for aarch64 or x84_64, depending on your host.
|
||||
1. You can also add the parameter `arm` or `x86` to the `./build.sh` script to build for a particular architecture.
|
||||
1. The result will be a binary in the `bin` sub directory.
|
||||
1. You can then run `./run.sh` for an interactive environment. In this case the source code will be copied to new `src-x` directory (where `x` depends on the architecture), so your changes do not disappear when the Docker container exits. This script also takes the parameter `arm` or `x86`.
|
||||
|
||||
Some functions are perhaps overly general, but that is because they are taken directly from the [EMG](https://nordicmessaging.se) source code.
|
||||
|
||||
|
|
@ -68,7 +66,7 @@ This way whitelisted addresses can never be blocked.
|
|||
|
||||
## TODO
|
||||
|
||||
- Dockerfile, for building x86 binaries on arm machines.
|
||||
- Better git/ssh setup.
|
||||
- IPv6
|
||||
- Other firewall backends, such as raw iptables.
|
||||
|
||||
|
|
|
|||
18
build.sh
Executable file
18
build.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
. ./setarch.sh
|
||||
|
||||
pf=linux/$arch
|
||||
img=autofw-$arch
|
||||
|
||||
export DOCKER_BUILDKIT=1
|
||||
|
||||
docker build \
|
||||
--platform $pf \
|
||||
-t $img \
|
||||
.
|
||||
|
||||
mkdir -p bin
|
||||
docker run --platform $pf -v $PWD/bin:/opt/mount --rm $img cp bin/autofw /opt/mount/autofw-$arch
|
||||
|
||||
exit 0
|
||||
|
||||
20
run.sh
Executable file
20
run.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ./setarch.sh
|
||||
|
||||
pf=linux/$arch
|
||||
img=autofw-$arch
|
||||
|
||||
srcdir=`pwd`/src-$arch
|
||||
if [ ! -d $srcdir ]; then
|
||||
mkdir -p $srcdir
|
||||
cp -a src/ $srcdir/
|
||||
fi
|
||||
srcbind="--mount type=bind,source=$srcdir,target=/opt/autofw"
|
||||
|
||||
docker run --rm -ti \
|
||||
--platform=$pf \
|
||||
`echo $srcbind` \
|
||||
$img \
|
||||
/bin/zsh
|
||||
|
||||
25
setarch.sh
Normal file
25
setarch.sh
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
hostarch=`arch`
|
||||
if [ $hostarch = arm64 ]; then
|
||||
arch=arm64
|
||||
else
|
||||
arch=amd64
|
||||
fi
|
||||
#arch=arm64
|
||||
#arch=amd64
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
arg=$1
|
||||
case $arg in
|
||||
arm)
|
||||
arch=arm64
|
||||
;;
|
||||
x86)
|
||||
arch=amd64
|
||||
;;
|
||||
*)
|
||||
echo ignored arg: $arg
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
Loading…
Add table
Reference in a new issue