Skip to content

Commit

Permalink
Add e2e envs to devcontainer (#2032)
Browse files Browse the repository at this point in the history
* add e2e envs to devcontainer

* style: Format code with gofumpt and prettier

* move Dockerfile

* refactor

* update readme for dev Dockerfile

* style: Format code with gofumpt and prettier

* remove unnecesary sudo

* Set the SHELL option -o pipefail before RUN with a pipe in

* replace wget to curl

* Update dockers/dev/README.md

Co-authored-by: Kiichiro YUKAWA <[email protected]>

* add link to the image

* update install make commands

* refactor comment

* update kubectl/install

---------

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Co-authored-by: Kiichiro YUKAWA <[email protected]>
  • Loading branch information
3 people authored May 22, 2023
1 parent e655f53 commit 23c422c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 49 deletions.
26 changes: 8 additions & 18 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
{
"name": "Vald",
"image": "vdaas/vald-dev-container:nightly",
"dockerFile": "../dockers/dev/Dockerfile",
"context": "..",
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],

"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"go.useGoProxyToCheckForToolUpdates": false,
"go.useLanguageServer": true,
"go.autocompleteUnimportedPackages": true,
"go.buildOnSave": true,
"go.vetOnSave": true,
"go.lintOnSave": true,
"go.testOnSave": true,
"go.gopath": "/go"
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"enableNonRootDocker": "true",
"moby": "true"
}
},
"extensions": [
"golang.Go",
"zxh404.vscode-proto3",
"wayou.vscode-todo-highlight",
"esbenp.prettier-vscode"
],
"postCreateCommand": "go version"
}
2 changes: 1 addition & 1 deletion Makefile.d/k3d.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ k3d/install: $(BINDIR)/k3d

$(BINDIR)/k3d:
mkdir -p $(BINDIR)
wget -q -O - "https://raw.githubusercontent.com/rancher/k3d/main/install.sh" | bash
curl -sS https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
chmod a+x $(BINDIR)/$(K3D_COMMAND)

.PHONY: k3d/start
Expand Down
5 changes: 3 additions & 2 deletions Makefile.d/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ $(BINDIR)/kubectl:
chmod a+x $(BINDIR)/kubectl
else
$(BINDIR)/kubectl:
curl -L "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" -o $(BINDIR)/kubectl
chmod a+x $(BINDIR)/kubectl
curl -LO "https://dl.k8s.io/release/$(shell curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod a+x ./kubectl
sudo mv ./kubectl $(BINDIR)/kubectl
endif

.PHONY: protobuf/install
Expand Down
22 changes: 8 additions & 14 deletions dockers/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@

ARG MAINTAINER="vdaas.org vald team <[email protected]>"

FROM ubuntu:devel AS builder

# skipcq: DOK-DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /tmp

# skipcq: DOK-DL3026
FROM mcr.microsoft.com/vscode/devcontainers/go:1 AS base
LABEL maintainer "${MAINTAINER}"
Expand Down Expand Up @@ -64,12 +52,18 @@ COPY versions versions
RUN make ngt/install \
&& make helm/install \
&& make helm-docs/install \
&& make kind/install \
&& make valdcli/install \
&& make yq/install \
&& make golangci-lint/install \
&& make reviewdog/install \
&& make protobuf/install \
&& make kubectl/install \
&& make protobuf/install
&& make k3d/install

# k9s installs the binary to the current user which is root for devcontainer
# so change the current user to vscode to user afterwards
USER vscode
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -sS https://webinstall.dev/k9s | bash

WORKDIR ${GOPATH}
17 changes: 3 additions & 14 deletions dockers/dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

`vald-dev-container` is designed for the development of Vald on Docker.

This image includes some libraries required for implementation and is based on `ubuntu:devel` image.
This image includes some libraries required to develop Vald and is based on [`mcr.microsoft.com/vscode/devcontainers/go:1`](https://hub.docker.com/_/microsoft-vscode-devcontainers) image.

<div align="center">
<img src="https://github.com/vdaas/vald/blob/main/assets/image/readme.svg?raw=true" width="50%" />
</div>

[![latest Image](https://img.shields.io/docker/v/vdaas/vald-dev-container/latest?label=vald-dev-container)](https://hub.docker.com/r/vdaas/vald-dev-container/tags?page=1&name=latest)
[![latest Image](https://img.shields.io/docker/v/vdaas/vald-dev-container/latest?label=vald-dev-container)](https://hub.docker.com/r/vdaas/vald-dev-container/tags?page=1&name=nightly)
[![License: Apache 2.0](https://img.shields.io/github/license/vdaas/vald.svg?style=flat-square)](https://opensource.org/licenses/Apache-2.0)
[![latest ver.](https://img.shields.io/github/release/vdaas/vald.svg?style=flat-square)](https://github.com/vdaas/vald/releases/latest)
[![Twitter](https://img.shields.io/badge/twitter-follow-blue?logo=twitter&style=flat-square)](https://twitter.com/vdaas_vald)
Expand All @@ -24,31 +24,20 @@ This image includes some libraries required for implementation and is based on `
- CPU instruction: requires `AVX2` or `AVX512`
- Tools: Docker

### linux/arm64

- CPU instruction: NOT Apple Silicon
- Tools: Docker

## Get Started

<!-- Get Started -->
<!-- Vald Agent NGT requires more chapter Agent Standalone -->

`vald-dev-container` is used for contributing to Vald's project.

```bash
docker pull vdaas/vald-dev-container
docker run -name vald-dev -dit vdaas/vald-dev-container
docker exec -it vald-dev /bin/bash
```
Please use this container with [our Dev Container settings](https://github.com/vdaas/vald/blob/main/.devcontainer/devcontainer.json).

## Versions

| tag | linux/amd64 | linux/arm64 | description |
| :------ | :---------: | :---------: | :------------------------------------------------------------------------------------------------------------------------------ |
| latest ||| the latest image is the same as the latest version of [vdaas/vald](https://github.com/vdaas/vald) repository version. |
| nightly ||| the nightly applies the main branch's source code of the [vdaas/vald](https://github.com/vdaas/vald) repository. |
| vX.Y.Z ||| the vX.Y.Z image applies the source code of the [vdaas/vald](https://github.com/vdaas/vald) repository. |
| pr-XXX ||| the pr-XXX image applies the source code of the pull request XXX of the [vdaas/vald](https://github.com/vdaas/vald) repository. |

## Dockerfile
Expand Down

0 comments on commit 23c422c

Please sign in to comment.