forked from grpc-ecosystem/grpc-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update devcontainer and build env (grpc-ecosystem#2320)
* Update outdated devcontainer settings * Add Docker images for plugins These will be used to push the plugins to the BSR to allow users to perform remote generation. * Update Dockerfile This is much nicer for Codespaces development * Update references to Github Docker registry * Switch to new image * Change working directory for new image * Flush bazel cache * Use vscode home directory for bazel cache
- Loading branch information
1 parent
e257a35
commit 359dc57
Showing
8 changed files
with
100 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,53 @@ | ||
FROM golang:1.17.0 | ||
|
||
# Warm apt cache and install dependencies | ||
# bzip2 is required by the node_tests (to extract its dependencies). | ||
# patch is required by bazel tests | ||
ENV NVM_DIR="/usr/local/share/nvm" | ||
ENV NVM_SYMLINK_CURRENT=true \ | ||
PATH=${NVM_DIR}/current/bin:${PATH} | ||
|
||
ARG VSCODE_SCRIPTS_VERSION="v0.193.0" | ||
ARG NODE_VERSION="10" | ||
# Run some common installation scripts for a nicer dev environment. In order: | ||
# Used to create non-root user and update system packages | ||
# https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/common.md | ||
# We use this to install Go tools used by gopls | ||
# https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/go.md | ||
# We use this to install Node | ||
# https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/node.md | ||
RUN apt-get update && \ | ||
apt-get install -y wget unzip \ | ||
openjdk-11-jre \ | ||
bzip2 \ | ||
patch | ||
wget "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/${VSCODE_SCRIPTS_VERSION}/script-library/common-debian.sh" && \ | ||
chmod +x ./common-debian.sh && \ | ||
./common-debian.sh false vscode automatic automatic true false && \ | ||
wget "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/${VSCODE_SCRIPTS_VERSION}/script-library/go-debian.sh" && \ | ||
chmod +x ./go-debian.sh && \ | ||
./go-debian.sh none /usr/local/go /go vscode false true && \ | ||
wget "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/${VSCODE_SCRIPTS_VERSION}/script-library/node-debian.sh" && \ | ||
chmod +x ./node-debian.sh && \ | ||
./node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" vscode true && \ | ||
rm common-debian.sh go-debian.sh node-debian.sh && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ | ||
wget \ | ||
unzip \ | ||
openjdk-11-jre \ | ||
bzip2 \ | ||
patch && \ | ||
apt-get clean -y && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Install swagger-codegen | ||
ENV SWAGGER_CODEGEN_VERSION=2.4.8 | ||
RUN wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${SWAGGER_CODEGEN_VERSION}/swagger-codegen-cli-${SWAGGER_CODEGEN_VERSION}.jar \ | ||
-O /usr/local/bin/swagger-codegen-cli.jar | ||
|
||
# Wrap the jar for swagger-codgen | ||
RUN echo -e '#!/bin/bash\njava -jar /usr/local/bin/swagger-codegen-cli.jar "$@"' > /usr/local/bin/swagger-codegen && \ | ||
-O /usr/local/bin/swagger-codegen-cli.jar && \ | ||
echo -e '#!/bin/bash\njava -jar /usr/local/bin/swagger-codegen-cli.jar "$@"' > /usr/local/bin/swagger-codegen && \ | ||
chmod +x /usr/local/bin/swagger-codegen | ||
|
||
# Install node, used by NVM | ||
ENV NODE_VERSION=v10.16.3 | ||
ENV NVM_VERSION=v0.35.0 | ||
RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash | ||
|
||
# Install Bazelisk as bazel to manage Bazel | ||
RUN go get github.com/bazelbuild/bazelisk && \ | ||
RUN go install github.com/bazelbuild/bazelisk@latest && \ | ||
mv $(which bazelisk) /usr/local/bin/bazel | ||
|
||
# Clean up | ||
RUN apt-get autoremove -y && \ | ||
apt-get remove -y wget \ | ||
unzip && \ | ||
rm -rf /var/lib/apt/lists/* | ||
# Install buildifier for bazel formatting | ||
RUN go install github.com/bazelbuild/buildtools/buildifier@latest | ||
|
||
# Give vscode ownership of GOPATH | ||
RUN chown -R vscode: /go | ||
|
||
USER vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. | ||
{ | ||
"dockerFile": "../.circleci/Dockerfile", | ||
"overrideCommand": true, | ||
// Set *default* container specific settings.json values on container create. | ||
"name": "Go", | ||
"build": { | ||
"dockerfile": "../Dockerfile", | ||
"args": { | ||
"NODE_VERSION": "10" | ||
} | ||
}, | ||
"settings": { | ||
"editor.formatOnSave": true, | ||
"terminal.integrated.shell.linux": "/bin/bash", | ||
"go.useGoProxyToCheckForToolUpdates": true, | ||
"go.toolsManagement.checkForUpdates": "local", | ||
"go.useLanguageServer": true, | ||
"go.gopath": "/go", | ||
"go.goroot": "/usr/local/go", | ||
"go.toolsGopath": "/go/bin", | ||
"bazel.buildifierExecutable": "/go/bin/buildifier", | ||
"bazel.buildifierFixOnFormat": true, | ||
"bazel.enableCodeLens": true, | ||
}, | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"golang.Go", | ||
"bazelbuild.vscode-bazel", | ||
], | ||
"postCreateCommand": "cd $(mktemp -d) && GO111MODULE=on go get golang.org/x/tools/gopls@latest github.com/bazelbuild/buildtools/buildifier@latest && cd -", | ||
"remoteUser": "vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM golang:1.17.0 as builder | ||
|
||
ARG RELEASE_VERSION | ||
|
||
# Buf plugins must be built for linux/amd64 | ||
ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0 | ||
RUN go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@${RELEASE_VERSION} | ||
|
||
FROM scratch | ||
|
||
COPY --from=builder /go/bin/protoc-gen-grpc-gateway /usr/local/bin/protoc-gen-grpc-gateway | ||
|
||
ENTRYPOINT ["/usr/local/bin/protoc-gen-grpc-gateway"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM golang:1.17.0 as builder | ||
|
||
ARG RELEASE_VERSION | ||
|
||
# Buf plugins must be built for linux/amd64 | ||
ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0 | ||
RUN go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@${RELEASE_VERSION} | ||
|
||
FROM scratch | ||
|
||
COPY --from=builder /go/bin/protoc-gen-openapiv2 /usr/local/bin/protoc-gen-openapiv2 | ||
|
||
ENTRYPOINT ["/usr/local/bin/protoc-gen-openapiv2"] |