Skip to content

Commit d09dd89

Browse files
authored
devcontainer to make it easier to contribute to this project (#7)
* Devcontainer * Move devcontainer definitions * dev containers! * Finish up dev container
1 parent 08b2fb1 commit d09dd89

File tree

5 files changed

+105
-1
lines changed

5 files changed

+105
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ARG VARIANT=1-bullseye
2+
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}
3+
4+
ARG NODE_VERSION="none"
5+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
6+
7+
RUN apt-get update && apt-get install redis build-essential libpng-dev -y
8+
9+
ENTRYPOINT ["sleep", "infinity"]

.devcontainer/devcontainer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "Go",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "app",
5+
"workspaceFolder": "/workspace",
6+
"updateContentCommand": "go mod download && go generate -tags tools -x ./...",
7+
// Add the IDs of extensions you want installed when the container is created.
8+
"extensions": [
9+
"golang.Go",
10+
"mtxr.sqltools",
11+
"mtxr.sqltools-driver-pg"
12+
],
13+
"settings": {
14+
"go.toolsManagement.checkForUpdates": "local",
15+
"go.useLanguageServer": true,
16+
"go.gopath": "/go",
17+
"go.goroot": "/usr/local/go",
18+
"sqltools.connections": [
19+
{
20+
"name": "Container database",
21+
"driver": "PostgreSQL",
22+
"previewLimit": 50,
23+
"server": "localhost",
24+
"port": 5432,
25+
"database": "postgres",
26+
"username": "postgres",
27+
"password": "REPLACE_ME"
28+
}
29+
]
30+
},
31+
"forwardPorts": [
32+
5432,
33+
9000,
34+
9001
35+
],
36+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
37+
"remoteUser": "vscode"
38+
}

.devcontainer/docker-compose.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: '3'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
args:
9+
VARIANT: "1-bullseye"
10+
NODE_VERSION: "none"
11+
volumes:
12+
- ..:/workspace:cached
13+
cap_add:
14+
- SYS_PTRACE
15+
network_mode: service:postgres
16+
17+
redis:
18+
image: redis:alpine
19+
network_mode: service:postgres
20+
21+
postgres:
22+
image: postgres:alpine
23+
command: postgres -N 500 -B 4096MB
24+
environment:
25+
POSTGRES_PASSWORD: REPLACE_ME
26+
ports:
27+
- 5432:5432
28+
- 6379:6379
29+
- 9000:9000
30+
- 9001:9001
31+
32+
minio:
33+
image: minio/minio
34+
network_mode: service:postgres
35+
entrypoint: sh
36+
command: -c 'mkdir -p /data/smr && /usr/bin/docker-entrypoint.sh minio server /data --console-address ":9001"'
37+
environment:
38+
MINIO_ROOT_USER: minio
39+
MINIO_ROOT_PASSWORD: minio123
40+
MINIO_ACCESS_KEY: REPLACE_ME_KEY
41+
MINIO_SECRET_KEY: REPLACE_ME_SECRET

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch smr-api",
9+
"type": "go",
10+
"request": "launch",
11+
"mode": "auto",
12+
"program": "${workspaceFolder}/cmd/api",
13+
"cwd": "${workspaceFolder}"
14+
}
15+
]
16+
}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ WORKDIR /app
2323
COPY static /app/static
2424
COPY migrations /app/migrations
2525
EXPOSE 5020
26-
ENTRYPOINT ["/api"]
26+
ENTRYPOINT ["/api"]

0 commit comments

Comments
 (0)