-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
146 additions
and
19 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Go | ||
on: [push] | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
|
||
- name: Install dependencies | ||
run: sudo apt install -y make wget llvm clang gcc git npm gulp libbpf-dev | ||
|
||
- name: Set asm version | ||
run: sudo ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/asm | ||
|
||
- name: Build with make | ||
run: sudo make release | ||
|
||
- name: Test with the Go CLI | ||
run: sudo go test -v ./... | ||
|
||
- name: docker login | ||
env: | ||
DOCKER_ACCESS_TOKEN: ${{secrets.DOCKER_ACCESS_TOKEN}} | ||
run: | | ||
docker login -u wagvpn -p $DOCKER_ACCESS_TOKEN | ||
- name: Build the Docker image | ||
run: docker build . --file Dockerfile --tag wagvpn/wag:$(date +%s) --tag wagvpn/wag | ||
|
||
- name: Docker Push | ||
run: docker push wagvpn/wag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM redhat/ubi9-minimal:latest | ||
|
||
RUN microdnf update -y | ||
RUN microdnf install -y iptables nc | ||
|
||
WORKDIR /app/wag | ||
|
||
COPY wag /usr/bin/wag | ||
COPY example_config.json /tmp | ||
|
||
COPY docker_entrypoint.sh / | ||
RUN chmod +x /docker_entrypoint.sh | ||
|
||
VOLUME /data | ||
VOLUME /cfg | ||
|
||
CMD ["/docker_entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
if [ ! -f /cfg/config.json ]; then | ||
echo "No config file found, generating from example. Ensure /data is mounted for persistence" | ||
cp /tmp/example_config.json /cfg/config.json | ||
sed -i "s|AN EXAMPLE KEY|$(wg genkey)|" /cfg/config.json | ||
sed -i "s|\"devices.db\"|\"/data/devices.db\"|" /cfg/config.json | ||
echo "Please edit your newly generated config file and start again" | ||
exit | ||
fi | ||
|
||
# trap for all processes created inside this block; a single Ctrl+C will stop them all | ||
(trap 'kill 0' SIGINT | ||
|
||
echo "WAG: start" | ||
wag start -config /cfg/config.json & | ||
|
||
while ! nc -z localhost 4433; do | ||
echo "Waiting WAG to become online on port 4433 ..." | ||
sleep 0.5 | ||
done | ||
|
||
U=$(wag webadmin -list | grep $WEB_USER | cut -d, -f1) | ||
if [ "$U" != "$WEB_USER" ]; then | ||
echo "WEBADMIN: add user $WEB_USER" | ||
wag webadmin -add -username "$WEB_USER" -password "$WEB_PWD" | ||
else | ||
echo "WEBADMIN: user $WEB_USER exists, nothing updated" | ||
fi | ||
|
||
# block until 'wag start' finishes | ||
wait ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
version: '3.4' | ||
services: | ||
wag-docker: | ||
container_name: wag | ||
env_file: | ||
- .env | ||
build: | ||
context: . | ||
args: | ||
WEB_USER: ${WEB_USER} | ||
WEB_PWD: ${WEB_PWD} | ||
ports: | ||
- '4433:4433/tcp' | ||
- '7080:7080/tcp' | ||
- '8009:8009/udp' | ||
- '443:443/tcp' | ||
cap_add: | ||
- NET_ADMIN | ||
- NET_RAW | ||
- SYS_ADMIN | ||
ulimits: | ||
# see PR #1 | ||
memlock: -1 | ||
nofile: | ||
soft: "65536" | ||
hard: "65536" | ||
# tests with complete reg/auth didn't require privileged, so it is optional | ||
# privileged: true | ||
volumes: | ||
- './cfg:/cfg:z' | ||
- './data:/data:z' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM debian:latest | ||
RUN apt update -y | ||
RUN apt upgrade -y | ||
RUN apt install -y make wget llvm clang gcc git npm gulp libbpf-dev | ||
RUN wget https://go.dev/dl/go1.19.4.linux-amd64.tar.gz | ||
RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz | ||
ENV PATH="$PATH:/usr/local/go/bin" | ||
RUN mkdir -p /build/ | ||
RUN chmod 777 /build/ | ||
WORKDIR /build | ||
ADD build-wag.sh . | ||
RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/asm | ||
RUN chmod 777 build-wag.sh | ||
ENTRYPOINT ["bash", "/build/build-wag.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
if [[ ! -d /wag ]]; then | ||
echo "/wag not present, please mount folder onto docker container with -v" | ||
exit 1 | ||
fi | ||
|
||
|
||
cd /wag | ||
mkdir /build/go | ||
export GOPATH=/build/go | ||
export GOCACHE=/build/ | ||
make release |