Skip to content

Commit 8c4812f

Browse files
Move dependency installation from Dockefile to devcontainer.json
1 parent f0b51ae commit 8c4812f

File tree

2 files changed

+27
-54
lines changed

2 files changed

+27
-54
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,11 @@
11
FROM ubuntu:jammy
22

3-
ADD https://raw.githubusercontent.com/gitpod-io/workspace-images/main/base/install-packages /usr/bin/install-packages
4-
RUN chmod +x /usr/bin/install-packages
5-
6-
RUN install-packages \
7-
zip unzip \
8-
jq \
9-
curl \
10-
ca-certificates \
11-
file \
12-
git \
13-
node.js
14-
15-
ENV GO_VERSION=1.24.0
16-
RUN echo "TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}" && \
17-
case "${TARGETPLATFORM:-linux/amd64}" in \
18-
"linux/arm64") \
19-
echo "GO_PLATFORM=linux-arm64" > /tmp/go_platform.env \
20-
;; \
21-
*) \
22-
echo "GO_PLATFORM=linux-amd64" > /tmp/go_platform.env \
23-
;; \
24-
esac
25-
26-
# Install Go and add it to PATH
27-
RUN . /tmp/go_platform.env && \
28-
curl -fsSL https://dl.google.com/go/go$GO_VERSION.$GO_PLATFORM.tar.gz | tar -C /usr/local -xzs
29-
30-
# Set Go environment variables
31-
ENV GOROOT=/usr/local/go
32-
ENV PATH=$GOROOT/bin:$PATH
33-
ENV GOPATH=/root/go
34-
ENV PATH=$GOPATH/bin:$PATH
35-
36-
# install VS Code Go tools for use with gopls as per https://github.com/golang/vscode-go/blob/master/docs/tools.md
37-
# also https://github.com/golang/vscode-go/blob/27bbf42a1523cadb19fad21e0f9d7c316b625684/src/goTools.ts#L139
38-
RUN go install -v github.com/uudashr/gopkgs/cmd/gopkgs@v2 \
39-
&& go install -v github.com/ramya-rao-a/go-outline@latest \
40-
&& go install -v github.com/cweill/gotests/gotests@latest \
41-
&& go install -v github.com/fatih/gomodifytags@latest \
42-
&& go install -v github.com/josharian/impl@latest \
43-
&& go install -v github.com/haya14busa/goplay/cmd/goplay@latest \
44-
&& go install -v github.com/go-delve/delve/cmd/dlv@latest \
45-
&& go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest \
46-
&& go install -v golang.org/x/tools/gopls@latest \
47-
&& go install -v honnef.co/go/tools/cmd/staticcheck@latest \
48-
&& rm -rf /root/.cache
49-
50-
ENV SHFMT_VERSION=3.10.0
51-
RUN curl -sSL -o /usr/local/bin/shfmt "https://github.com/mvdan/sh/releases/download/v${SHFMT_VERSION}/shfmt_v${SHFMT_VERSION}_linux_amd64" && \
52-
chmod 755 /usr/local/bin/shfmt
53-
543
# Install latest Leeway release
55-
RUN . /tmp/go_platform.env && \
4+
ENV GO_PLATFORM=linux-amd64
5+
RUN apt-get update && apt-get install -y curl && \
566
LATEST_LEEWAY_VERSION=$(curl -s https://api.github.com/repos/gitpod-io/leeway/releases/latest | grep '"tag_name"' | sed 's/.*"tag_name": "v\([^"]*\)".*/\1/') && \
577
curl -L -o /tmp/leeway.tar.gz https://github.com/gitpod-io/leeway/releases/download/v${LATEST_LEEWAY_VERSION}/leeway_Linux_${GO_PLATFORM#linux-}.tar.gz && \
588
tar -xzf /tmp/leeway.tar.gz -C /tmp && \
599
install -m 755 /tmp/leeway /usr/local/bin/ && \
60-
rm /tmp/leeway.tar.gz
10+
rm /tmp/leeway.tar.gz && \
11+
apt-get clean && rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,32 @@
44
"context": "..",
55
"dockerfile": "Dockerfile"
66
},
7+
"features": {
8+
"ghcr.io/devcontainers/features/node:1": {
9+
"version": "lts",
10+
"nodeGypDependencies": true,
11+
"yarn": true
12+
},
13+
"ghcr.io/devcontainers/features/go:1": {
14+
"version": "1.24.0"
15+
},
16+
"ghcr.io/devcontainers/features/common-utils:2": {
17+
"installZsh": false,
18+
"configureZshAsDefaultShell": false,
19+
"username": "root",
20+
"upgradePackages": true
21+
},
22+
"ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
23+
"ghcr.io/devcontainers-contrib/features/jq-apt-get:1": {},
24+
"ghcr.io/devcontainers-contrib/features/shfmt:1": {
25+
"version": "3.10.0"
26+
}
27+
},
728
"runArgs": [
829
"--privileged",
930
"--security-opt=seccomp=unconfined",
1031
"--network=host"
1132
],
12-
"containerUser": "root"
33+
"containerUser": "root",
34+
"postCreateCommand": "go install -v github.com/uudashr/gopkgs/cmd/gopkgs@v2 && go install -v github.com/ramya-rao-a/go-outline@latest && go install -v github.com/cweill/gotests/gotests@latest && go install -v github.com/fatih/gomodifytags@latest && go install -v github.com/josharian/impl@latest && go install -v github.com/haya14busa/goplay/cmd/goplay@latest && go install -v github.com/go-delve/delve/cmd/dlv@latest && go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest && go install -v golang.org/x/tools/gopls@latest && go install -v honnef.co/go/tools/cmd/staticcheck@latest"
1335
}

0 commit comments

Comments
 (0)