tangled
alpha
login
or
join now
tree.fail
/
plcdns
15
fork
atom
PLC Directory over DNS (experiment)
15
fork
atom
overview
issues
pulls
pipelines
repo url, dockerfile etc
tree.fail
5 months ago
724d4d34
19798c75
+92
-3
4 changed files
expand all
collapse all
unified
split
.dockerignore
Dockerfile
README.md
go.mod
+40
.dockerignore
···
1
1
+
# .dockerignore
2
2
+
# Git
3
3
+
.git
4
4
+
.gitignore
5
5
+
.github
6
6
+
7
7
+
# Documentation
8
8
+
README.md
9
9
+
LICENSE
10
10
+
*.md
11
11
+
12
12
+
# Tests
13
13
+
*_test.go
14
14
+
coverage.out
15
15
+
coverage.html
16
16
+
17
17
+
# Build artifacts
18
18
+
plcdns
19
19
+
*.exe
20
20
+
*.dll
21
21
+
*.so
22
22
+
*.dylib
23
23
+
*.test
24
24
+
*.out
25
25
+
26
26
+
# IDE
27
27
+
.vscode
28
28
+
.idea
29
29
+
*.swp
30
30
+
*.swo
31
31
+
*~
32
32
+
33
33
+
# OS
34
34
+
.DS_Store
35
35
+
Thumbs.db
36
36
+
37
37
+
# Docker
38
38
+
Dockerfile
39
39
+
docker-compose.yml
40
40
+
.dockerignore
+49
Dockerfile
···
1
1
+
# Dockerfile
2
2
+
FROM golang:1.21-alpine AS builder
3
3
+
4
4
+
# Install build dependencies
5
5
+
RUN apk add --no-cache git ca-certificates tzdata
6
6
+
7
7
+
# Set working directory
8
8
+
WORKDIR /app
9
9
+
10
10
+
# Copy go mod files
11
11
+
COPY go.mod go.sum ./
12
12
+
13
13
+
# Download dependencies
14
14
+
RUN go mod download
15
15
+
16
16
+
# Copy source code
17
17
+
COPY . .
18
18
+
19
19
+
# Build the application
20
20
+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o plcdns .
21
21
+
22
22
+
# Final stage
23
23
+
FROM scratch
24
24
+
25
25
+
# Copy CA certificates from builder
26
26
+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
27
27
+
28
28
+
# Copy timezone data
29
29
+
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
30
30
+
31
31
+
# Copy the binary
32
32
+
COPY --from=builder /app/plcdns /plcdns
33
33
+
34
34
+
# Expose DNS ports (UDP and TCP)
35
35
+
EXPOSE 53/udp
36
36
+
EXPOSE 53/tcp
37
37
+
38
38
+
# Set default environment variables
39
39
+
ENV DNS_PORT=53
40
40
+
41
41
+
# Run as non-root user (note: for port 53, container must run with --cap-add=NET_BIND_SERVICE)
42
42
+
USER 65534:65534
43
43
+
44
44
+
# Health check
45
45
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
46
46
+
CMD ["/plcdns", "-h"] || exit 1
47
47
+
48
48
+
# Run the application
49
49
+
ENTRYPOINT ["/plcdns"]
+2
-2
README.md
···
18
18
19
19
```bash
20
20
# Clone the repository
21
21
-
git clone https://github.com/yourusername/plcdns.git
21
21
+
git clone https://tangled.org/@tree.fail/plcdns
22
22
cd plcdns
23
23
24
24
# Install dependencies
···
44
44
### Using Go Install
45
45
46
46
```bash
47
47
-
go install github.com/yourusername/plcdns@latest
47
47
+
go install tangled.org/@tree.fail/plcdns@latest
48
48
```
49
49
50
50
## Usage
+1
-1
go.mod
···
1
1
-
module did-plc-dns
1
1
+
module plcdns
2
2
3
3
go 1.21
4
4