Added Dev Container / Updated Contributor Doc (#299)

* added basic dev container

* added docker-lock

* Added helm

* updated contributing instructions

* fixed spacing

Co-authored-by: Michael Perel <michaelsethperel@microsoft.com>
Co-authored-by: Evan Louie <evlouie@gmail.com>
This commit is contained in:
michaelperel 2020-04-29 17:07:06 -04:00 коммит произвёл GitHub
Родитель e8a80bcfb6
Коммит 2b389c9f2a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 102 добавлений и 34 удалений

27
.devcontainer/Dockerfile Normal file
Просмотреть файл

@ -0,0 +1,27 @@
FROM ubuntu:bionic
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG GO_VERSION=1.14.2
ARG GOLANGCI_LINT_VERSION=1.25.0
ARG HELM_VERSION=3.1.2
ARG DOCKER_VERSION=19.03.8
ARG DOCKER_LOCK_VERSION=0.2.0
RUN apt-get update && \
apt-get -y install vim curl wget gcc software-properties-common && \
add-apt-repository ppa:git-core/ppa -y && \
apt-get update && \
apt-get install git -y && \
curl -fsSL "https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz" | tar -xz && \
mv linux-amd64/helm /usr/local/bin && \
rm -rf linux-amd64 && \
curl -fsSL "https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz" | tar -xz -C /usr/local docker/docker && \
mkdir -p "${HOME}/.docker/cli-plugins" && \
curl -fsSL "https://github.com/michaelperel/docker-lock/releases/download/v${DOCKER_LOCK_VERSION}/docker-lock-linux" -o "${HOME}/.docker/cli-plugins/docker-lock" && \
chmod +x "${HOME}/.docker/cli-plugins/docker-lock" && \
curl -fsSL "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" | tar -xz -C /usr/local && \
curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b "${HOME}/go/bin" "v${GOLANGCI_LINT_VERSION}" && \
echo "export PATH=/usr/local/go/bin:${HOME}/go/bin:/usr/local/docker:${PATH}" >> "${HOME}/.bashrc" && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Просмотреть файл

@ -0,0 +1,47 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/docker-existing-dockerfile
{
"name": "Dev Dockerfile",
"dockerFile": "Dockerfile",
// The optional 'runArgs' property can be used to specify additional runtime arguments.
"runArgs": [
// Enable go debugger
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
// map host docker daemon into container for sibling containers
"-v",
"/var/run/docker.sock:/var/run/docker.sock"
],
"settings": {
"files.eol": "\n",
"terminal.integrated.shell.linux": "/bin/bash",
// Go recommended settings with modules: https://github.com/golang/tools/blob/master/gopls/doc/vscode.md#vscode
"go.useLanguageServer": true,
"go.lintTool": "golangci-lint",
"go.lintFlags": [
"--fast"
],
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
// Optional: Disable snippets, as they conflict with completion ranking.
"editor.snippetSuggestions": "none"
},
"[go.mod]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"gopls": {
// Add parameter placeholders when completing a function.
"usePlaceholders": true
}
},
"extensions": [
"ms-vscode.go"
]
}

Просмотреть файл

@ -0,0 +1,12 @@
{
"dockerfiles": {
"Dockerfile": [
{
"name": "ubuntu",
"tag": "bionic",
"digest": "b58746c8a89938b8c9f5b77de3b8cf1fe78210c696ab03a1442e235eea65d84f"
}
]
},
"composefiles": {}
}

Просмотреть файл

@ -32,47 +32,29 @@ intended to solve via "Closes #xyz" where is the issue number that is addressed.
## Cloning Fabrikate
Fabrikate is written in [golang](https://golang.org/) so the first step is to
make sure you have a fully functioning go development enviroment.
If you intend to make contributions to Fabrikate (versus just build it), the
first step is to
[fork Fabrikate on Github](https://github.com/microsoft/fabrikate) into your own
account.
Next, clone Fabrikate into your GOPATH (which defaults to \$HOME/go) with
`go get` (substitute your GitHub username for `microsoft` below if you forked
the repo):
Fabrikate comes with a development container for
[Visual Studio Code](https://code.visualstudio.com/docs/remote/containers).
```sh
$ go get github.com/microsoft/fabrikate
```
> Note: If you do not want to use the development container, ensure you have
go version >= 1.12. Fabrikate uses
[go modules](https://github.com/golang/go/wiki/Modules), so either git clone
your fork outside of the `GOPATH` or set `GO111MODULE=on` if you want to work
within the `GOPATH`.
If you forked Fabrikate, this will clone your fork into
`$GOPATH/<github username>/fabrikate`. You will want to move to
\$GOPATH/microsoft/fabrikate such that the imports in the project work
correctly.
### Configuring git
Under `$GOPATH/microsoft/fabrikate` set up git so that you can push changes to
the fork:
```sh
$ git remote add <name> <github_url_of_fork>
```
For example:
```sh
$ git remote add myremote https://github.com/octocat/Spoon-Knife
```
To push changes to the fork:
```sh
$ git push myremote mycurrentbranch
```
To use the development container:
1. Install Microsoft's
[Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
2. Git clone your fork of the repo.
3. Open the project in VSCode.
4. In the command palette (`ctrl+shift+p` on Windows/Linux, `command+shift+p` on Mac),
select "Reopen in Container".
5. In the command palette type: "Go: Install/Update Tools" and select all.
6. When all tools are finished installing, in the command palette type: "Developer: Reload Window".
## Building Fabrikate