Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dev-container #401

Merged
merged 3 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM mcr.microsoft.com/devcontainers/go:bullseye

RUN apt-get update && apt-get install -y \
curl \
git \
&& rm -rf /var/lib/apt/lists/*

RUN go install mvdan.cc/gofumpt@latest
ENV PATH="/root/go/bin:${PATH}"
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
RUN golangci-lint --version
54 changes: 54 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "Docker in Docker",
"build": {
"dockerfile": "./Dockerfile",
"context": "."
},
"features": {
"ghcr.io/devcontainers/features/common-utils:1": {
"installZsh": "true",
"upgradePackages": "false",
"uid": "1000",
"gid": "1000",
"installOhMyZsh": "true",
"nonFreePackages": "true"
},
"ghcr.io/devcontainers/features/docker-from-docker:1": {
"version": "latest",
"enableNonRootDocker": "true",
"moby": "true"
},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/go:1": {}
},
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "~/go",
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"go.lintTool": "golangci-lint",
"gopls": {
"formatting.gofumpt": true,
"usePlaceholders": false // add parameter placeholders when completing a function
},
"files.eol": "\n"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"golang.Go"
]
}
}
// TODO: make this work.
// "postStartCommand": "echo \"alias gr=\\\"go run /workspaces/lazydocker/main.go\\\"\" >> ~/.zhsrc"
}
26 changes: 25 additions & 1 deletion pkg/gui/views.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
package gui

import (
"os"

"github.com/fatih/color"
"github.com/jesseduffield/gocui"
"github.com/samber/lo"
)

// See https://github.com/xtermjs/xterm.js/issues/4238
// VSCode is soon to fix this in an upcoming update.
// Once that's done, we can scrap the HIDE_UNDERSCORES variable
var (
underscoreEnvChecked bool
hideUnderscores bool
)

func hideUnderScores() bool {
if !underscoreEnvChecked {
hideUnderscores = os.Getenv("TERM_PROGRAM") == "vscode"
underscoreEnvChecked = true
}

return hideUnderscores
}

type Views struct {
// side panels
Project *gocui.View
Expand Down Expand Up @@ -155,7 +174,12 @@ func (gui *Gui) getInformationContent() string {
return informationStr
}

donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.Donate)
attrs := []color.Attribute{color.FgMagenta}
if !hideUnderScores() {
attrs = append(attrs, color.Underline)
}

donate := color.New(attrs...).Sprint(gui.Tr.Donate)
return donate + " " + informationStr
}

Expand Down
3 changes: 3 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM alpine:latest

COPY . /app
25 changes: 25 additions & 0 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "3.5"
services:
my-service:
build:
dockerfile: Dockerfile
context: .
command: /app/print-random-stuff.sh
depends_on:
- my-service2
ports:
- 123:321

my-service2:
build:
dockerfile: Dockerfile
context: .
command: /app/print-random-stuff.sh
ports:
- 12345:12345

my-service3:
build:
dockerfile: Dockerfile
context: .
command: /app/print-random-stuff.sh
7 changes: 7 additions & 0 deletions test/print-random-stuff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

while true
do
echo $((1 + $RANDOM % 10))
sleep 1
done
24 changes: 0 additions & 24 deletions test/printrandom/Dockerfile

This file was deleted.

26 changes: 0 additions & 26 deletions test/printrandom/main.go

This file was deleted.

Binary file removed test/printrandom/printrandom
Binary file not shown.