Skip to content

Commit

Permalink
build: docker support (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
hero-intelligent authored Nov 15, 2023
1 parent e3d6280 commit a7252d9
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 1 deletion.
81 changes: 81 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Publish Docker Image

on:
workflow_dispatch:
push:
branches:
- "main"
release:
types: [prereleased,released]


jobs:


publish-docker-image:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Prepare Tag
# Borrowed from daeuniverse/dae
id: prep
env:
REF: ${{ github.ref }}
run: |
if [[ "$REF" == "refs/tags/v"* ]]; then
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
tag=${tag:1}
else
tag=$(git log -1 --format="%cd" --date=short | sed s/-//g)
fi
echo "IMAGE=daeuniverse/dae-wing" >> $GITHUB_OUTPUT
echo "TAG=$tag" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to ghrc.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ github.repository_owner }}
password: ${{ secrets.QUAY_PASS }}

- name: Build image
uses: docker/build-push-action@v5
with:
context: .
build-args: VERSION=${{ steps.prep.outputs.TAG }}
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/386,linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ github.repository }}:latest
${{ github.repository }}:${{ steps.prep.outputs.TAG }}
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ steps.prep.outputs.TAG }}
quay.io/${{ github.repository }}:latest
quay.io/${{ github.repository }}:${{ steps.prep.outputs.TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# wing/Dockerfile
FROM golang:1.21-bookworm as builder

WORKDIR /build

RUN apt-get update
RUN apt-get install -y git make llvm-15 clang-15

ENV CGO_ENABLED=0
ENV CLANG=clang-15
ARG VERSION=self-build

COPY . .

RUN make APPNAME=dae-wing VERSION=$VERSION

FROM alpine

WORKDIR /etc/dae-wing

RUN mkdir -p /usr/local/share/dae-wing
RUN wget -O /usr/local/share/dae-wing/geoip.dat https://github.com/v2rayA/dist-v2ray-rules-dat/raw/master/geoip.dat
RUN wget -O /usr/local/share/dae-wing/geosite.dat https://github.com/v2rayA/dist-v2ray-rules-dat/raw/master/geosite.dat
COPY --from=builder /build/dae-wing /usr/local/bin

EXPOSE 2023

CMD ["dae-wing"]
ENTRYPOINT ["dae-wing", "run", "-c", "."]
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,23 @@
<img src="https://custom-icon-badges.herokuapp.com/github/last-commit/daeuniverse/dae-wing?logo=history&logoColor=white" alt="lastcommit"/>
</p>

## Run
## Prerequisites

[Git](https://git-scm.com), [Docker](https://www.docker.com), [Golang](https://go.dev), [GNU GCC](https://gcc.gnu.org)

## Fetch the source code

> Clone the repository with git submodules (dae-core) using git
```shell
git clone https://github.com/daeuniverse/dae-wing
cd dae-wing

# Initialize git submodules
git submodule update --init --recursive
```

## Run Locally

To run the api only:

Expand All @@ -25,6 +41,34 @@ go run -exec sudo . run
# go build -o dae-wing && sudo ./dae-wing run -c ./ --api-only
```

## Run with Docker

> This feature is implemented for container orchestration with the dashboards that call this API, which also facilitates testing and development.
Prebuilt image is available at `ghcr.io`. To pull this prebuilt image, you can replace image name into `ghcr.io/daeuniverse/dae-wing`.

To build container from source:

```bash
# use docker compose
sudo docker compose up -d

# Or you can build then run with CLI
# build image
sudo docker build -t dae-wing .

# run container
sudo docker run -d \
--privileged \
--network=host \
--pid=host \
--restart=always \
-v /sys:/sys \
-v /etc/dae-wing:/etc/dae-wing \
--name=dae-wing \
dae-wing
```

## API

API is powered by [GraphQL](https://graphql.org/). UI developers can export schema and write queries and mutations easily.
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'

services:
dae-wing:
privileged: true
network_mode: host
pid: host
build: .
container_name: dae-wing
volumes:
- /sys:/sys
- /etc/dae-wing:/etc/dae-wing

0 comments on commit a7252d9

Please sign in to comment.