Skip to content

Commit

Permalink
cleanup: devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kallepan committed Oct 6, 2023
1 parent ba88f48 commit 05a1081
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.dockerignore
Dockerfile
docker-compose.yaml
devcontainer.json
README.md
22 changes: 21 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
FROM mcr.microsoft.com/devcontainers/go:1.21-bookworm
FROM golang:1.21.2-bookworm

LABEL name="GoLang Dev Container" \
description="GoLang Dev Container" \
version="1.0.0"

# Install tools
RUN apt-get update && apt-get install -y \
curl \
git \
gnupg2 \
lsb-release \
sudo \
unzip \
wget \
zsh \
&& rm -rf /var/lib/apt/lists/*

# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
ARG USERNAME=vscode
RUN useradd -m $USERNAME -s /bin/bash \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& chown -R $USERNAME:$USERNAME /tmp

# Expose port 8080
EXPOSE ${PORT}
20 changes: 18 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,31 @@
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspace",
"postCreateCommand":"cd src && go mod download && go install github.com/google/wire/cmd/wire@latest",
"postCreateCommand": "cd src && go mod download && go mod tidy",

"customizations": {
"vscode": {
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.lintOnSave": "package",
"go.lintTool": "golangci-lint",
"go.testFlags": [
"-v",
"-count=1",
"-timeout=30s",
"-parallel=4"
]
},
"extensions": [
"golang.Go",
"GitHub.copilot",
"DavidAnson.vscode-markdownlint"
]
}
}
},

// Comment out the next line to run as root instead. Linux users, update Dockerfile
"remoteUser": "vscode"
}
8 changes: 4 additions & 4 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ services:
- db:/var/lib/postgresql/data

devcontainer:
build:
context: .
dockerfile: Dockerfile
build: .
env_file:
- ../.dev.env
volumes:
- ..:/workspace:cached
- ../.:/workspace:cached
command: sleep infinity
ports:
- 8080:8080
Expand Down
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.devcontainer
.git
.github
.dockerignore
.gitignore
alpine.Dockerfile
debian.Dockerfile
LICENSE
README.md
title.png

0 comments on commit 05a1081

Please sign in to comment.