Skip to content

Commit 0644ca4

Browse files
committed
Add devcontainer
1 parent 360a50e commit 0644ca4

File tree

3 files changed

+117
-6
lines changed

3 files changed

+117
-6
lines changed

.devcontainer/compose.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
services:
2+
feed-feeder:
3+
deploy:
4+
replicas: 0
5+
article-feeder:
6+
deploy:
7+
replicas: 0
8+
keyword-matcher:
9+
deploy:
10+
replicas: 0
11+
raindrop-integration:
12+
deploy:
13+
replicas: 0
14+
watchtower:
15+
deploy:
16+
replicas: 0
17+
devcontainer:
18+
build:
19+
context: ./golang/
20+
dockerfile: Dockerfile
21+
target: devcontainer
22+
environment:
23+
- NATS_URL=nats-server
24+
volumes:
25+
# Mounts the project folder to '/workspace'. While this file is in .devcontainer,
26+
# mounts are relative to the first file in the list, which is a level up.
27+
- .:/workspace:cached
28+
29+
# [Optional] Required for ptrace-based debuggers like C++, Go, and Rust
30+
cap_add:
31+
- SYS_PTRACE
32+
security_opt:
33+
- seccomp:unconfined
34+
35+
# Overrides default command so things don't shut down after the process ends.
36+
command: /bin/sh -c "while sleep 1000; do :; done"

.devcontainer/devcontainer.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"name": "ⁿⁿᵃ",
3+
"dockerComposeFile": [
4+
"../compose.yml", // First file determines root
5+
"./compose.yml"
6+
],
7+
"service": "devcontainer",
8+
"workspaceFolder": "/workspace",
9+
"customizations": {
10+
"vscode": {
11+
"settings": {
12+
"dotfiles.repository": "https://github.com/heussd/dotfiles",
13+
"dotfiles.targetPath": "~/.dotfiles",
14+
"dotfiles.installCommand": ".install.sh",
15+
"files.eol": "\n",
16+
"editor.formatOnSave": true,
17+
"go.buildTags": "",
18+
"go.toolsEnvVars": {
19+
"CGO_ENABLED": "0"
20+
},
21+
"go.useLanguageServer": true,
22+
"go.testEnvVars": {
23+
"CGO_ENABLED": "1"
24+
},
25+
"go.testFlags": ["-v", "-race"],
26+
"go.testTimeout": "10s",
27+
"go.coverOnSingleTest": true,
28+
"go.coverOnSingleTestFile": true,
29+
"go.coverOnTestPackage": true,
30+
"go.lintTool": "golangci-lint",
31+
"go.lintOnSave": "package",
32+
"[go]": {
33+
"editor.codeActionsOnSave": {
34+
"source.organizeImports": "always"
35+
}
36+
},
37+
"gopls": {
38+
"usePlaceholders": false,
39+
"staticcheck": true,
40+
"formatting.gofumpt": true
41+
},
42+
"remote.extensionKind": {
43+
"ms-azuretools.vscode-docker": "workspace"
44+
}
45+
},
46+
"extensions": [
47+
"golang.go",
48+
"davidanson.vscode-markdownlint",
49+
"ms-azuretools.vscode-docker", // Docker integration and linting
50+
"shardulm94.trailing-spaces", // Show trailing spaces
51+
"Gruntfuggly.todo-tree", // Highlights TODO comments
52+
"stkb.rewrap", // rewrap comments after n characters on one line
53+
"github.vscode-pull-request-github", // Github interaction
54+
"bajdzis.vscode-database", // Supports connections to mysql or postgres, over SSL, socked
55+
"IBM.output-colorizer", // Colorize your output/test logs
56+
"github.copilot" // AI code completion
57+
]
58+
}
59+
},
60+
"containerEnv": {
61+
"GOROOT2": "./golang"
62+
},
63+
"shutdownAction": "stopCompose"
64+
}

golang/Dockerfile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-bullseye AS builder
1+
FROM golang:1.24.2-bullseye AS base
22

33
ENV GO111MODULE=on
44

@@ -7,6 +7,22 @@ COPY go.mod .
77
COPY go.sum .
88
RUN go mod download
99

10+
11+
# https://github.com/drone/ca-certs/blob/master/Dockerfile
12+
FROM alpine:3.6 AS alpine
13+
RUN apk add -U --no-cache ca-certificates
14+
15+
16+
FROM base as devcontainer
17+
18+
RUN go install -v golang.org/x/tools/gopls@latest
19+
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
20+
RUN go install github.com/nats-io/natscli/nats@latest
21+
22+
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
23+
24+
FROM base as builder
25+
1026
COPY pkg ./pkg
1127
COPY internal ./internal
1228

@@ -15,11 +31,6 @@ COPY _${MAIN} ./_${MAIN}
1531
RUN CGO_ENABLED=0 go build -a -ldflags '-s' -o goapp.bin /app/_${MAIN}
1632

1733

18-
# https://github.com/drone/ca-certs/blob/master/Dockerfile
19-
FROM alpine:3.6 AS alpine
20-
RUN apk add -U --no-cache ca-certificates
21-
22-
2334
FROM scratch
2435
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
2536
COPY --from=builder /app/goapp.bin /goapp.bin

0 commit comments

Comments
 (0)