Skip to content

Commit 04fdc6d

Browse files
committed
feat: timeouts for socket connection
1 parent b3961ab commit 04fdc6d

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

arch.dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@
5656
ENV SOCKET_PROXY_VOLUME="/run/proxy" \
5757
SOCKET_PROXY_DOCKER_SOCKET="/run/docker.sock" \
5858
SOCKET_PROXY_UID=${APP_UID} \
59-
SOCKET_PROXY_GID=${APP_GID}
59+
SOCKET_PROXY_GID=${APP_GID} \
60+
SOCKET_PROXY_KEEPALIVE=10 \
61+
SOCKET_PROXY_TIMEOUT=30 \
62+
SOCKET_PROXY_DEADLINE=60
6063

6164
# :: multi-stage
6265
COPY --from=distroless / /

go/socket-proxy/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func main(){
130130
signals()
131131

132132
// setup proxy to docker socket as root
133-
docketSockerDialer := &net.Dialer{KeepAlive: 1 * time.Second}
133+
docketSockerDialer := &net.Dialer{KeepAlive: os.Getenv("SOCKET_PROXY_KEEPALIVE") * time.Second, Timeout: os.Getenv("SOCKET_PROXY_TIMEOUT") * time.Second, Deadline: os.Getenv("SOCKET_PROXY_DEADLINE") * time.Second}
134134
dockerSocket, err := docketSockerDialer.Dial("unix", os.Getenv("SOCKET_PROXY_DOCKER_SOCKET"))
135135
if err != nil {
136136
log.Fatalf("could not access docker socket %v", err)

project.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ socket-proxy-1 | socket-proxy:
1010
socket-proxy-1 | user: "0:991"
1111
```
1212

13-
${{ content_uvp }} Good question! All the other images on the market that do exactly the same don’t do or offer these options:
13+
${{ content_uvp }} Good question! Because ...
1414

1515
${{ github:> [!IMPORTANT] }}
16-
${{ github:> }}* This image runs the proxy part as a specific UID/GID (not root), most other images run everything as root
17-
${{ github:> }}* This image uses a single binary, most other images use apps like Nginx or HAProxy (bloat)
18-
${{ github:> }}* This image has no shell since it is 100% distroless, most other images run on a distro like Debian or Alpine with full shell access (security)
19-
${{ github:> }}* This image does not ship with any critical or high rated CVE and is automatically maintained via CI/CD, most other images mostly have no CVE scanning or code quality tools in place
20-
${{ github:> }}* This image is created via a secure, pinned CI/CD process and immune to upstream attacks, most other images have upstream dependencies that can be exploited
21-
${{ github:> }}* This image contains a proper health check that verifies the app is actually working, most other images have either no health check or only check if a port is open or ping works
22-
${{ github:> }}* This image exposes the socket as a UNIX socket and TCP socket, most other images only expose it via a TCP socket
23-
${{ github:> }}* This image works as read-only, most other images need to write files to the image filesystem
16+
${{ github:> }}* ... this image exposes the socket not as root but as 1000:1000
17+
${{ github:> }}* ... this image has no shell since it is [distroless](https://github.com/11notes/RTFM/blob/main/linux/container/image/distroless.md)
18+
${{ github:> }}* ... this image is auto updated to the latest version via CI/CD
19+
${{ github:> }}* ... this image has a health check
20+
${{ github:> }}* ... this image runs read-only
21+
${{ github:> }}* ... this image is automatically scanned for CVEs before and after publishing
22+
${{ github:> }}* ... this image is created via a secure and pinned CI/CD process
23+
${{ github:> }}* ... this image is very small
2424

25-
If you value security, simplicity and the ability to interact with the maintainer and developer of an image. Using my images is a great start in that direction.
25+
If you value security, simplicity and optimizations to the extreme, then this image might be for you.
2626

2727
${{ content_compose }}
2828

@@ -31,6 +31,9 @@ ${{ content_environment }}
3131
| `SOCKET_PROXY_DOCKER_SOCKET` | path to the actual docker socket | /run/docker.sock |
3232
| `SOCKET_PROXY_UID` | the UID used to run the proxy parts | 1000 |
3333
| `SOCKET_PROXY_GID` | the GID used to run the proxy parts | 1000 |
34+
| `SOCKET_PROXY_KEEPALIVE` | connection keep alive interval to SOCKET_PROXY_DOCKER_SOCKET | 10 |
35+
| `SOCKET_PROXY_TIMEOUT` | connection max. timeout to SOCKET_PROXY_DOCKER_SOCKET | 30 |
36+
| `SOCKET_PROXY_DEADLINE` | connection max. deadline to SOCKET_PROXY_DOCKER_SOCKET | 60 |
3437

3538
${{ content_source }}
3639

0 commit comments

Comments
 (0)