-
Notifications
You must be signed in to change notification settings - Fork 1
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
Copyonwrite/248/add devcontainer setup #286
Changes from 5 commits
98fb552
e47184c
dc0188e
ff68139
9b85a7a
5d81a4a
cc5e069
4904a0d
17bd65b
31a5b82
f91492d
0b97ff2
de458c0
ab09f7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
FROM mcr.microsoft.com/devcontainers/go | ||
|
||
WORKDIR /go/src/github.com/cloudoperators/heureka | ||
ADD . . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "heureka & MariaDB", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "app", | ||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", | ||
"postCreateCommand": "make", | ||
"forwardPorts": [ | ||
80, | ||
"mariadb:3306" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
services: | ||
app: | ||
build: | ||
context: .. | ||
dockerfile: .devcontainer/Dockerfile | ||
|
||
volumes: | ||
- ../..:/workspaces:cached | ||
- ../internal/database/mariadb/init/schema.sql:/app_sqlschema/schema.sql | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: sleep infinity | ||
|
||
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. | ||
network_mode: service:mariadb | ||
|
||
environment: | ||
# MariaDB Connection | ||
DB_ADDRESS: mariadb | ||
DB_PORT: 3306 | ||
DB_USER: mariadb | ||
DB_PASSWORD: mariadb | ||
DB_ROOT_PASSWORD: mariadb | ||
DB_NAME: heureka | ||
DB_SCHEMA: /app_sqlschema/schema.sql | ||
|
||
|
||
SEED_MODE: true | ||
AUTH_TYPE: token | ||
AUTH_TOKEN_SECRET: xxx | ||
|
||
mariadb: | ||
image: mariadb:latest | ||
container_name: mariadb | ||
restart: unless-stopped | ||
|
||
environment: | ||
MARIADB_USER: mariadb | ||
MARIADB_PASSWORD: mariadb | ||
MARIADB_DATABASE: heureka | ||
MARIADB_ROOT_PASSWORD: mariadb | ||
|
||
volumes: | ||
- ../.mariadb-dev/:/var/lib/mysql |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
DB_USER=mariadb | ||
DB_PASSWORD=mariadb | ||
DB_ROOT_PASSWORD=mariadb | ||
DB_NAME=heureka | ||
DB_ADDRESS=mariadb | ||
DB_PORT=3306 | ||
DB_SCHEMA=internal/database/mariadb/init/schema.sql | ||
|
||
DB_CONTAINER_IMAGE=mariadb:latest | ||
|
||
LOG_PRETTY_PRINT=true | ||
|
||
LOCAL_TEST_DB=true | ||
|
||
SEED_MODE=true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,10 @@ | |
# vendor/ | ||
.vscode | ||
.DS_Store | ||
cmd/heureka/__debug_bin* | ||
|
||
# Heureka specifics | ||
build/ | ||
.db/ | ||
.env | ||
.env | ||
.mariadb-dev/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch K8sScanner", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"cwd": "${workspaceFolder}", | ||
"program": "scanner/k8s-assets/main.go", | ||
"envFile": "${workspaceFolder}/scanner/k8s-assets/.env" | ||
}, | ||
{ | ||
"name": "Launch NvdScanner", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"cwd": "${workspaceFolder}", | ||
"program": "scanner/nvd/main.go", | ||
"envFile": "${workspaceFolder}/scanner/nvd/.env" | ||
}, | ||
{ | ||
"name": "Launch KeppelScanner", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"cwd": "${workspaceFolder}", | ||
"program": "scanner/keppel/main.go", | ||
"envFile": "${workspaceFolder}/scanner/keppel/.env" | ||
}, | ||
{ | ||
"name": "Launch Heureka DevContainer", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "cmd/heureka/main.go", | ||
"args": [ | ||
"-mode", | ||
"seed" | ||
], | ||
"cwd": "${workspaceFolder}", | ||
"envFile": "${workspaceFolder}/.env-devcontainer", | ||
"showLog": true | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,12 +87,37 @@ docker-compose --profile db --profile heureka up | |
|
||
### Makefile | ||
|
||
Alternatively, the application can be started by using the provided Makefile: | ||
The application can be started by using the provided Makefile: | ||
|
||
``` | ||
make start-all-heureka | ||
``` | ||
|
||
### Devcontainers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Requirements would be helpful: Which Docker environements is the expected to work on? e.g.: Does it also work with Podman? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also: If we decide not to investigate the Intellij/OSX combination, we may add to the documentation on which systems this setup is recommended/working. |
||
|
||
Devcontainers is a new standard for development environments based on (docker) | ||
[devcontainer](./.devcontainer). | ||
|
||
At the moment devcontainers are supported by Visual Studio Code and IDEA IDEs. | ||
|
||
For Microsoft Visual Studio code, install the remote container extension via | ||
Ctrl-P and this command: | ||
|
||
ext install ms-vscode-remote.remote-containers | ||
|
||
When opening the root folder in Visual Studio code a prompt will ask you to | ||
open the project in a dev container, which you should. | ||
|
||
Once inside the devcontainer the provided launch.json is configured to allow | ||
launching heureka and running the unit and integration tests. | ||
|
||
At the moment there is a known issue with the permissions of the .mariadb-dev | ||
folder. This folder has to be deleted every time after using the devcontainers. | ||
Use the following command in the root folder of heureka: | ||
|
||
sudo rm -rf .mariadb-dev | ||
|
||
|
||
### Tests | ||
|
||
#### Mockery | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to remove this line on IntelliJ to make the dev-container start