Skip to content

Commit

Permalink
Merge pull request Place1#13 from antoinebou13/update
Browse files Browse the repository at this point in the history
Small update to the website and the readme and added a docker-compose file
  • Loading branch information
Place1 authored Mar 11, 2020
2 parents 8e35e75 + 2dc4b92 commit 47893ca
Show file tree
Hide file tree
Showing 19 changed files with 192 additions and 95 deletions.
60 changes: 60 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
### Default ignore for this project ###
config.yaml
data/
./wg-access-server

### Code ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### Go ###
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

### Go Patch ###
/vendor/
/Godeps/

### react ###
.DS_*
*.log
logs
**/*.backup.*
**/*.back.*

### website react app ###

# dependencies
website/node_modules
website/.pnp
website/.pnp.js

# testing
website/coverage

# production
website/build

# misc
website/.DS_Store
website/.env.local
website/.env.development.local
website/.env.test.local
website/.env.production.local

website/npm-debug.log*
website/yarn-debug.log*
website/yarn-error.log*
website/yarn.lock


30 changes: 28 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,56 @@
### Build stage for the website frontend
FROM node:10 as website

WORKDIR /code

COPY ./website/package.json ./
COPY ./website/package-lock.json ./

# install dependency
RUN npm install

COPY ./website/ ./

RUN npm run build

### Build stage for the website backend server
FROM golang:1.13.8 as server

WORKDIR /code

# Environment variable
ENV GOOS=linux
ENV GARCH=amd64
ENV CGO_ENABLED=0
ENV GO111MODULE=on

COPY ./go.mod ./
COPY ./go.sum ./

RUN go mod download

COPY ./proto/ ./proto/
COPY ./main.go ./main.go
COPY ./internal/ ./internal

RUN go build -o server

### Server
FROM alpine:3.10
RUN apk add iptables
RUN apk add wireguard-tools

# Environment variable
ENV CONFIG="/config.yaml"
ENV STORAGE_DIRECTORY="/data"

RUN apk add iptables
RUN apk add wireguard-tools
RUN apk add curl

# Copy the final build for the frontend and backend
COPY --from=server /code/server /server
COPY --from=website /code/build /website/build

HEALTHCHECK --interval=5m --timeout=3s CMD curl -f http://localhost:8000/ || exit 1

# Command to start the server
CMD /server
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ network as well.
Here's a quick command to run the server to try it out.

If you open your browser using your LAN ip address you can even connect your
phone to try it out: for example, i'll open my browser at http://192.168.0.15:8000
using my laptop's LAN IP address.
phone to try it out: for example, i'll open my browser at http://192.168.0.XX:8000
using the local LAN IP address.

```
You can connect to the web server on the local machine browser at http://localhost:8000

```bash
docker run \
-it \
--rm \
Expand All @@ -48,11 +50,21 @@ docker run \
place1/wg-access-server
```

## Running with Docker-Compose

You modify the docker-compose.yml file for you need then run this following command.

```bash
docker-compose up -d
```

You can connect to the web server on the local machine browser at http://localhost:8000

## Configuration

You can configure the server using a yaml configuration file. Just mount the file into the container like this:

```
```bash
docker run \
... \
-v $(pwd)/config.yaml:/config.yaml \
Expand Down Expand Up @@ -205,8 +217,8 @@ The software is made up a Golang Server and React App.
Here's how I develop locally:
2. run `cd website && npm install && npm start` to get the frontend running on `:3000`
3. run `sudo go run ./main.go` to get the server running on `:8000`
1. run `cd website && npm install && npm start` to get the frontend running on `:3000`
2. run `sudo go run ./main.go` to get the server running on `:8000`

Here are some notes about the development configuration:

Expand Down
8 changes: 4 additions & 4 deletions codegen.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

OUT_DIR="$DIR/proto/proto"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
OUT_DIR="$SCRIPT_DIR/proto/proto"

mkdir -p "$OUT_DIR" || true

Expand All @@ -12,4 +11,5 @@ protoc \
proto/*.proto \
--go_out="plugins=grpc:$OUT_DIR"

cd website && npm run codegen
cd website || exit
npm run codegen
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3.7"
services:
wg-access-server:
# to build the docker image from the source
# build:
# dockerfile: Dockerfile
# context: .
image: place1/wg-access-server
container_name: wg-access-server
cap_add:
- NET_ADMIN
volumes:
- "wg-access-server-data:/data"
# - "config.yaml/config.yaml" # if you have a custom confg file
ports:
- "8000:8000/tcp"
- "51820:51820/udp"
devices:
- "/dev/net/tun:/dev/net/tun"

# shared volumes with the host
volumes:
wg-access-server-data:
driver: local
18 changes: 9 additions & 9 deletions docs/index.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: v1
entries:
wg-access-server:
- apiVersion: v2
appVersion: 0.0.9
created: "2020-03-08T15:27:38.5587792+11:00"
description: A Wireguard VPN Access Server
digest: e8d795290f577d5d5678619dac42e1a667407aa7128a682da30f26db9f383a1c
name: wg-access-server
urls:
- https://place1.github.io/wg-access-server/charts/wg-access-server-0.0.9.tgz
version: 0.0.9
- apiVersion: v2
appVersion: 0.0.9
created: "2020-03-08T15:27:38.5587792+11:00"
description: A Wireguard VPN Access Server
digest: e8d795290f577d5d5678619dac42e1a667407aa7128a682da30f26db9f383a1c
name: wg-access-server
urls:
- https://place1.github.io/wg-access-server/charts/wg-access-server-0.0.9.tgz
version: 0.0.9
generated: "2020-03-08T15:27:38.5581672+11:00"
14 changes: 9 additions & 5 deletions publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
.read() \
.decode('utf-8')
tags = json.loads(r).get('results', [])
print('current docker tags:', sorted([t.get('name') for t in tags], reverse=True))
print('current docker tags:', sorted(
[t.get('name') for t in tags], reverse=True))

# tag the new image
version = input('Version: ')
docker_tag=f"place1/wg-access-server:{version}"
docker_tag = f"place1/wg-access-server:{version}"
# subprocess.run(['docker', 'build', '-t', docker_tag, '.'])

# update the helm chart and quickstart manifest
Expand All @@ -26,9 +27,12 @@
yaml.dump(chart, f, default_flow_style=False)
f.truncate()
with open('deploy/k8s/quickstart.yaml', 'w') as f:
subprocess.run(['helm', 'template', '--name-template', 'quickstart', 'deploy/helm/wg-access-server/'], stdout=f)
subprocess.run(['helm', 'package', 'deploy/helm/wg-access-server/', '--destination', 'docs/charts/'])
subprocess.run(['helm', 'repo', 'index', 'docs/', '--url', 'https://place1.github.io/wg-access-server'])
subprocess.run(['helm', 'template', '--name-template',
'quickstart', 'deploy/helm/wg-access-server/'], stdout=f)
subprocess.run(['helm', 'package', 'deploy/helm/wg-access-server/',
'--destination', 'docs/charts/'])
subprocess.run(['helm', 'repo', 'index', 'docs/', '--url',
'https://place1.github.io/wg-access-server'])

# commit changes
subprocess.run(['git', 'add', 'deploy'])
Expand Down
24 changes: 0 additions & 24 deletions website/.gitignore

This file was deleted.

24 changes: 14 additions & 10 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
# React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:
### `yarn start` or `npm run start`

### `yarn start`
Runs the app in the development mode.

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
The page will reload if you make edits.

You will also see any lint errors in the console.

### `yarn test`
### `yarn test` or `npm run test`

Launches the test runner in the interactive watch mode.

Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`
### `yarn build` or `npm run build`

Builds the app for production to the `build` folder.

Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br />
The build is minified and the filenames include the hashes.

Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`
### `yarn eject` or `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

Expand Down
Loading

0 comments on commit 47893ca

Please sign in to comment.