mirror of
https://github.com/h44z/wg-portal
synced 2025-02-26 05:49:14 +00:00
- update github actions
- update docker build - move default database to /app/data (#179) - move config file location to /app/config
This commit is contained in:
parent
6284bc8a01
commit
248518d239
@ -55,7 +55,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/go:1.20-node
|
- image: cimg/go:1.21-node
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
build-and-release:
|
build-and-release:
|
||||||
|
34
.github/workflows/docker-publish.yml
vendored
34
.github/workflows/docker-publish.yml
vendored
@ -7,7 +7,7 @@ name: Docker
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ master, stable ]
|
||||||
# Publish vX.X.X tags as releases.
|
# Publish vX.X.X tags as releases.
|
||||||
tags: [ 'v*.*.*' ]
|
tags: [ 'v*.*.*' ]
|
||||||
|
|
||||||
@ -24,13 +24,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the repo
|
- name: Check out the repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Get Version
|
- name: Get Version
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -41,27 +41,28 @@ jobs:
|
|||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: h44z/wg-portal
|
images: wgportal/wg-portal
|
||||||
flavor: |
|
flavor: |
|
||||||
latest=true
|
latest=true
|
||||||
prefix=
|
prefix=
|
||||||
suffix=
|
suffix=
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=tag
|
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern=v{{major}}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
@ -81,13 +82,13 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Get Version
|
- name: Get Version
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -100,7 +101,7 @@ jobs:
|
|||||||
# https://github.com/docker/login-action
|
# https://github.com/docker/login-action
|
||||||
- name: Log into registry ${{ env.REGISTRY }}
|
- name: Log into registry ${{ env.REGISTRY }}
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@ -110,7 +111,7 @@ jobs:
|
|||||||
# https://github.com/docker/metadata-action
|
# https://github.com/docker/metadata-action
|
||||||
- name: Extract Docker metadata
|
- name: Extract Docker metadata
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
flavor: |
|
flavor: |
|
||||||
@ -119,13 +120,14 @@ jobs:
|
|||||||
suffix=
|
suffix=
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=tag
|
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern=v{{major}}
|
||||||
|
|
||||||
# Build and push Docker image with Buildx (don't push on PR)
|
# Build and push Docker image with Buildx (don't push on PR)
|
||||||
# https://github.com/docker/build-push-action
|
# https://github.com/docker/build-push-action
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
10
Dockerfile
10
Dockerfile
@ -4,7 +4,7 @@
|
|||||||
######-
|
######-
|
||||||
# Start from the latest golang base image as builder image (only used to compile the code)
|
# Start from the latest golang base image as builder image (only used to compile the code)
|
||||||
######-
|
######-
|
||||||
FROM golang:1.20 as builder
|
FROM golang:1.21 as builder
|
||||||
|
|
||||||
ARG BUILD_IDENTIFIER
|
ARG BUILD_IDENTIFIER
|
||||||
ENV ENV_BUILD_IDENTIFIER=$BUILD_IDENTIFIER
|
ENV ENV_BUILD_IDENTIFIER=$BUILD_IDENTIFIER
|
||||||
@ -46,5 +46,11 @@ COPY --from=builder /build/dist/wg-portal /app/wg-portal
|
|||||||
# Set the Current Working Directory inside the container
|
# Set the Current Working Directory inside the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# by default, the web-portal is reachable on port 8888
|
||||||
|
EXPOSE 8888/tcp
|
||||||
|
|
||||||
|
# the database and config file can be mounted from the host
|
||||||
|
VOLUME [ "/app/data", "/app/config" ]
|
||||||
|
|
||||||
# Command to run the executable
|
# Command to run the executable
|
||||||
CMD [ "/app/wg-portal" ]
|
ENTRYPOINT [ "/app/wg-portal" ]
|
15
README.md
15
README.md
@ -1,4 +1,4 @@
|
|||||||
# WireGuard Portal (V2 - alpha testing)
|
# WireGuard Portal (v2 - testing)
|
||||||
|
|
||||||
[](https://travis-ci.com/h44z/wg-portal)
|
[](https://travis-ci.com/h44z/wg-portal)
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
@ -6,10 +6,13 @@
|
|||||||
[](https://goreportcard.com/report/github.com/h44z/wg-portal)
|
[](https://goreportcard.com/report/github.com/h44z/wg-portal)
|
||||||

|

|
||||||

|

|
||||||
[](https://hub.docker.com/r/h44z/wg-portal/)
|
[](https://hub.docker.com/r/wgportal/wg-portal/)
|
||||||
|
|
||||||
> :warning: **IMPORTANT** Version 2 is currently under development and may contain bugs. It is currently not advised to use this version
|
> :warning: **IMPORTANT** Version 2 is currently under development and may contain bugs. It is currently not advised to use this version
|
||||||
in production. Use version [1.0.18](https://github.com/h44z/wg-portal/releases) instead.
|
in production. Use version [v1](https://github.com/h44z/wg-portal/tree/stable) instead.
|
||||||
|
|
||||||
|
Since the project was accepted by the Docker-Sponsored Open Source Program, the Docker image location has moved to: https://hub.docker.com/r/wgportal/wg-portal.
|
||||||
|
Please update the Docker image from **h44z/wg-portal** to **wgportal/wg-portal**.
|
||||||
|
|
||||||
A simple, web based configuration portal for [WireGuard](https://wireguard.com).
|
A simple, web based configuration portal for [WireGuard](https://wireguard.com).
|
||||||
The portal uses the WireGuard [wgctrl](https://github.com/WireGuard/wgctrl-go) library to manage existing VPN
|
The portal uses the WireGuard [wgctrl](https://github.com/WireGuard/wgctrl-go) library to manage existing VPN
|
||||||
@ -41,10 +44,12 @@ The configuration portal supports using a database (SQLite, MySQL, MsSQL or Post
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
You can configure WireGuard Portal using a yaml configuration file.
|
You can configure WireGuard Portal using a yaml configuration file.
|
||||||
The filepath of the yaml configuration file defaults to **config.yml** in the working directory of the executable.
|
The filepath of the yaml configuration file defaults to **config/config.yml** in the working directory of the executable.
|
||||||
It is possible to override the configuration filepath using the environment variable **WG_PORTAL_CONFIG**.
|
It is possible to override the configuration filepath using the environment variable **WG_PORTAL_CONFIG**.
|
||||||
For example: `WG_PORTAL_CONFIG=/home/test/config.yml ./wg-portal-amd64`.
|
For example: `WG_PORTAL_CONFIG=/home/test/config.yml ./wg-portal-amd64`.
|
||||||
|
|
||||||
|
By default, WireGuard Portal uses a SQLite database. The database is stored in **data/sqlite.db** in the working directory of the executable.
|
||||||
|
|
||||||
### Configuration Options
|
### Configuration Options
|
||||||
The following configuration options are available:
|
The following configuration options are available:
|
||||||
|
|
||||||
@ -128,7 +133,7 @@ The following configuration options are available:
|
|||||||
| debug | database | false | Debug database statements (log each statement). |
|
| debug | database | false | Debug database statements (log each statement). |
|
||||||
| slow_query_threshold | database | | A threshold for slow database queries. If the threshold is exceeded, a warning message will be logged. |
|
| slow_query_threshold | database | | A threshold for slow database queries. If the threshold is exceeded, a warning message will be logged. |
|
||||||
| type | database | sqlite | The database type. Allowed values: sqlite, mssql, mysql or postgres. |
|
| type | database | sqlite | The database type. Allowed values: sqlite, mssql, mysql or postgres. |
|
||||||
| dsn | database | sqlite.db | The database DSN. For example: user:pass@tcp(1.2.3.4:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local |
|
| dsn | database | data/sqlite.db | The database DSN. For example: user:pass@tcp(1.2.3.4:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local |
|
||||||
| request_logging | web | false | Log all HTTP requests. |
|
| request_logging | web | false | Log all HTTP requests. |
|
||||||
| external_url | web | http://localhost:8888 | The URL where a client can access WireGuard Portal. |
|
| external_url | web | http://localhost:8888 | The URL where a client can access WireGuard Portal. |
|
||||||
| listening_address | web | :8888 | The listening port of the web server. |
|
| listening_address | web | :8888 | The listening port of the web server. |
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
version: '3.6'
|
version: '3.6'
|
||||||
services:
|
services:
|
||||||
wg-portal:
|
wg-portal:
|
||||||
image: h44z/wg-portal:2.0.0-alpha1
|
image: h44z/wg-portal:v2
|
||||||
container_name: wg-portal
|
container_name: wg-portal
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
logging:
|
logging:
|
||||||
@ -15,5 +15,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- /etc/wireguard:/etc/wireguard
|
- /etc/wireguard:/etc/wireguard
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
environment:
|
- ./config:/app/config
|
||||||
- EXTERNAL_URL=http://localhost:8888
|
# restart: no
|
||||||
|
# command: ["-migrateFrom=/app/data/wg_portal.db"]
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
|||||||
module github.com/h44z/wg-portal
|
module github.com/h44z/wg-portal
|
||||||
|
|
||||||
go 1.20
|
go 1.21
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/coreos/go-oidc/v3 v3.6.0
|
github.com/coreos/go-oidc/v3 v3.6.0
|
||||||
|
10
hooks/build
10
hooks/build
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# File needs to be called /hooks/build relative to the Dockerfile.
|
|
||||||
# Some environment variables are injected into the build hook, see: https://docs.docker.com/docker-hub/builds/advanced/.
|
|
||||||
|
|
||||||
GIT_SHORT_HASH=$(echo $SOURCE_COMMIT | cut -c1-7)
|
|
||||||
echo "Build hook running for git hash $GIT_SHORT_HASH"
|
|
||||||
docker build --build-arg BUILD_IDENTIFIER=$DOCKER_TAG \
|
|
||||||
--build-arg BUILD_VERSION=$GIT_SHORT_HASH \
|
|
||||||
-t $IMAGE_NAME .
|
|
@ -87,7 +87,7 @@ func defaultConfig() *Config {
|
|||||||
|
|
||||||
cfg.Database = DatabaseConfig{
|
cfg.Database = DatabaseConfig{
|
||||||
Type: "sqlite",
|
Type: "sqlite",
|
||||||
DSN: "sqlite.db",
|
DSN: "data/sqlite.db",
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Web = WebConfig{
|
cfg.Web = WebConfig{
|
||||||
@ -140,7 +140,7 @@ func GetConfig() (*Config, error) {
|
|||||||
|
|
||||||
// override config values from YAML file
|
// override config values from YAML file
|
||||||
|
|
||||||
cfgFileName := "config.yml"
|
cfgFileName := "config/config.yml"
|
||||||
if envCfgFileName := os.Getenv("WG_PORTAL_CONFIG"); envCfgFileName != "" {
|
if envCfgFileName := os.Getenv("WG_PORTAL_CONFIG"); envCfgFileName != "" {
|
||||||
cfgFileName = envCfgFileName
|
cfgFileName = envCfgFileName
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user