Prechádzať zdrojové kódy

Added Dockerfile and docker-compose.yml

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
Andrea Barberio 1 rok pred
rodič
commit
d477d9b2cc
4 zmenil súbory, kde vykonal 67 pridanie a 2 odobranie
  1. 2 2
      .github/workflows/lint.yml
  2. 43 0
      Dockerfile
  3. 11 0
      README.md
  4. 11 0
      docker-compose.yml

+ 2 - 2
.github/workflows/lint.yml

@@ -20,8 +20,8 @@ jobs:
       - name: golangci-lint
         uses: golangci/golangci-lint-action@v4
         with:
-          version: v1.56.2
-          args: --timeout=120s
+          version: v1.62.2
+          args: --timeout=5m
 
           # Optional: show only new issues if it's a pull request. The default value is `false`.
           only-new-issues: true

+ 43 - 0
Dockerfile

@@ -0,0 +1,43 @@
+FROM ubuntu:22.04
+
+LABEL BUILD="docker build -t coredhcp/coredhcp -f Dockerfile ."
+LABEL RUN="docker run --rm -it coredhcp/coredhcp"
+
+# Install dependencies
+RUN apt-get update &&                          \
+    apt-get install -y --no-install-recommends \
+        sudo \
+	iproute2 \
+        # to fetch the Go toolchain
+        ca-certificates \
+        wget \
+        # for go get
+        git \
+	# for CGo support
+	build-essential \
+        && \
+    rm -rf /var/lib/apt/lists/*
+
+# install Go
+WORKDIR /tmp
+RUN set -exu; \
+    wget https://golang.org/dl/go1.23.4.linux-amd64.tar.gz ;\
+    tar -C / -xvzf go1.23.4.linux-amd64.tar.gz
+ENV PATH="$PATH:/go/bin:/build/bin"
+ENV GOPATH=/go:/build
+
+ENV PROJDIR=/build/src/github.com/coredhcp/coredhcp
+RUN mkdir -p $PROJDIR
+COPY . $PROJDIR
+
+# build coredhcp
+RUN set -exu ;\
+    cd $PROJDIR/cmds/coredhcp ;\
+    go get -v ./... ;\
+    CGO_ENABLED=1 go build ;\
+    cp coredhcp /bin
+
+EXPOSE 67/udp
+EXPOSE 547/udp
+
+CMD coredhcp --conf /etc/coredhcp/config.yaml

+ 11 - 0
README.md

@@ -77,6 +77,17 @@ INFO[2019-01-05T22:29:21Z] DHCPv6Message
 ...
 ```
 
+## Docker
+
+There is a [Dockerfile](./Dockerfile) and a [docker-compose.yml](./docker-compose.yml).
+
+Docker compose expects a configuration file under `/etc/coredhcp/config.yaml`, and it is
+mapped to `./etc/coredhcp/config.yaml` when using `docker compose`. You can adjust the exported
+volume in `docker-compose.yml` to point to a different configuration file on the host file system.
+
+There is an example configuration file [config.yml.example](./cmds/coredhcp/config.yml.example)
+that you can use as a starting point.
+
 # Plugins
 
 CoreDHCP is heavily based on plugins: even the core functionalities are

+ 11 - 0
docker-compose.yml

@@ -0,0 +1,11 @@
+services:
+  coredhcp:
+    privileged: true
+    build:
+      context: .
+      dockerfile: Dockerfile
+    ports:
+      - 67:67
+      - 547:547
+    volumes:
+      - ./etc/coredhcp/:/etc/coredhcp/