-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With this change one can use githubs codespaces feature that will create a development environment on a vm. A click in the Github UI will create an instance. Its free for all(single instance) except cooperations. With a simple click on now ends up with a fully functional development environment. This includes: - UAA Instance - Minio S3 Blobstore - Nginx Reverse Proxy for package uploads - Mariadb and Postgresdb - A service broker with configureable behaviour (CATS Broker) - Run Configurations for VSCode and Intellij/Rubymine to start right away - Tunneling SSH from the container to localhost to be able to connect with Intellij/Rubymines new remote ssh feature At startup the DBs are set up, migrated and seeded and also all bundle packages get installed. The setup of a codespaces takes rughly 5 minutes. Once a codespace is stopped it wont get recreated at startup so startup times are nearly instant. Also changes to the environment are persisted between restarts. Only if one choses to throw away a codespace and recreate it, thats when the build times come on top of starting times and any temporary change to the environment is gone. We will use this as our main development environment for CC. In case it gets unmaintained its a simple delete of a folder that is just used by the github codespaces functionality. Also this enables super simple start on developing in CC for most endpoints (excluding diego and loggregator functionality for now).
- Loading branch information
1 parent
6f7c462
commit 059d758
Showing
26 changed files
with
1,051 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
.devcontainer/configs/intellij/.idea/runConfigurations/_Mariadb__CC-Unittests.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
.devcontainer/configs/intellij/.idea/runConfigurations/_Mariadb__CC.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
.devcontainer/configs/intellij/.idea/runConfigurations/_Postgres__CC-Unittests.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
.devcontainer/configs/intellij/.idea/runConfigurations/_Postgres__CC.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,40 @@ | ||
{ | ||
// 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": "[Postgres] CC", | ||
"type": "Ruby", | ||
"request": "launch", | ||
"useBundler": true, | ||
"cwd": "${workspaceRoot}", | ||
"program": "bin/cloud_controller", | ||
"args": [ | ||
"-c", | ||
"tmp/cloud_controller.yml" | ||
], | ||
"env": { | ||
"DB": "postgres", | ||
"DB_CONNECTION_STRING": "postgres://postgres:supersecret@localhost:5432/ccdb" | ||
} | ||
}, | ||
{ | ||
"name": "[Mariadb] CC", | ||
"type": "Ruby", | ||
"request": "launch", | ||
"useBundler": true, | ||
"cwd": "${workspaceRoot}", | ||
"program": "bin/cloud_controller", | ||
"args": [ | ||
"-c", | ||
"tmp/cloud_controller.yml" | ||
], | ||
"env": { | ||
"DB": "mysql", | ||
"DB_CONNECTION_STRING": "mysql2://root:supersecret@localhost:3306/ccdb" | ||
} | ||
} | ||
] | ||
} |
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,35 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
{ | ||
"name": "Cloud Controller Dev Environment", | ||
"dockerComposeFile": ["../docker-compose.yml", "docker-compose.override.yml"], | ||
"service": "codespace", | ||
"runServices": [ | ||
"postgres", | ||
"mariadb", | ||
"uaa", | ||
"minio", | ||
"catsbroker", | ||
"nginx" | ||
], | ||
"workspaceFolder": "/workspace", | ||
"initializeCommand": ".devcontainer/scripts/codespaces_init.sh", | ||
"onCreateCommand": ".devcontainer/scripts/codespaces_start.sh", | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": {}, | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"rebornix.ruby", | ||
"ms-azuretools.vscode-docker", | ||
"hbenl.vscode-test-explorer", | ||
"connorshea.vscode-ruby-test-adapter", | ||
"oderwat.indent-rainbow", | ||
"2gua.rainbow-brackets" | ||
] | ||
} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [80,1234,9292,9393,9000,9001,8080,3306,5432] | ||
} |
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,19 @@ | ||
version: "3.3" | ||
services: | ||
|
||
# Dev Container | ||
codespace: | ||
container_name: codespace | ||
build: | ||
context: .devcontainer/images/devcontainer | ||
dockerfile: Dockerfile | ||
restart: unless-stopped | ||
command: /bin/sh -c "while sleep 1000; do :; done" | ||
volumes: | ||
- .:/workspace:cached | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
network_mode: host | ||
cap_add: | ||
- SYS_PTRACE | ||
security_opt: | ||
- seccomp:unconfined |
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,17 @@ | ||
FROM ruby:2.7-alpine | ||
|
||
RUN apk --no-cache add git make curl jq build-base \ | ||
&& git clone https://github.com/cloudfoundry/cf-acceptance-tests \ | ||
--filter=blob:none \ | ||
--depth=1 \ | ||
-b $(curl -s https://api.github.com/repos/cloudfoundry/cf-acceptance-tests/releases/latest | jq -r '.tag_name') \ | ||
--single-branch | ||
|
||
WORKDIR /cf-acceptance-tests/assets/service_broker | ||
RUN git checkout $(curl -s https://api.github.com/repos/cloudfoundry/cf-acceptance-tests/releases/latest | jq -r '.tag_name') \ | ||
&& bundle install | ||
|
||
EXPOSE 80 | ||
|
||
ENTRYPOINT ["bundle"] | ||
CMD ["exec", "rackup", "--host", "0.0.0.0"] |
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,6 @@ | ||
FROM mcr.microsoft.com/vscode/devcontainers/ruby:3.1 | ||
|
||
COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/ | ||
COPY setup.sh /tmp/setup.sh | ||
USER vscode | ||
RUN /tmp/setup.sh && sudo rm /tmp/setup.sh |
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,49 @@ | ||
#!/bin/bash | ||
set -Eeuo pipefail | ||
# shellcheck disable=SC2064 | ||
trap "pkill -P $$" EXIT | ||
|
||
setupAptPackages () { | ||
# CF CLI is not available for aarch64 :( | ||
if [[ $(uname -m) == aarch64 ]]; then | ||
PACKAGES="postgresql-client postgresql-client-common mariadb-client ruby-dev" | ||
else | ||
PACKAGES="cf8-cli postgresql-client postgresql-client-common mariadb-client ruby-dev" | ||
fi | ||
|
||
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - | ||
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list | ||
sudo apt-get update | ||
export DEBIAN_FRONTEND="noninteractive" && echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections | ||
sudo apt-get install -o Dpkg::Options::="--force-overwrite" $PACKAGES -y | ||
} | ||
|
||
setupRubyGems () { | ||
gem install cf-uaac | ||
} | ||
|
||
setupCredhubCli () { | ||
set -x | ||
wget "$(curl -s https://api.github.com/repos/cloudfoundry/credhub-cli/releases/latest | | ||
jq -r '.assets[] | select(.name|match("credhub-linux.*")) | .browser_download_url')" -O /tmp/credhub.tar.gz | ||
cd /tmp | ||
sudo tar -xzf /tmp/credhub.tar.gz && sudo rm -f /tmp/credhub.tar.gz && sudo mv /tmp/credhub /usr/bin | ||
} | ||
|
||
setupYqCli () { | ||
sudo wget "$(curl -s https://api.github.com/repos/mikefarah/yq/releases/latest | | ||
jq -r '.assets[] | select(.name|match("linux_amd64$")) | .browser_download_url')" -O /usr/bin/yq | ||
sudo chmod +x /usr/bin/yq | ||
} | ||
|
||
echo """ | ||
export COMPOSE_DOCKER_CLI_BUILD=1 | ||
export DOCKER_BUILDKIT=1 | ||
""" > ~/.bashrc | ||
|
||
setupAptPackages | ||
setupRubyGems | ||
setupCredhubCli | ||
setupYqCli | ||
|
||
trap "" EXIT |
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,22 @@ | ||
FROM alpine | ||
|
||
RUN apk --no-cache add build-base pcre-dev openssl-dev gzip curl jq zlib-dev \ | ||
&& NGINX_VERSION=$(curl -s https://nginx.org/en/download.html | grep -o -E -m 1 "nginx-[0-9]+\.[0-9]+\.[0-9]+" | cut -d'-' -f2 | head -n 1) \ | ||
&& UPLOAD_VERSION=$(curl -s https://api.github.com/repos/fdintino/nginx-upload-module/tags | jq -r '.[0].name') \ | ||
&& wget -P /tmp https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && tar -zxvf /tmp/nginx-${NGINX_VERSION}.tar.gz -C /tmp \ | ||
&& wget -P /tmp https://github.com/fdintino/nginx-upload-module/archive/${UPLOAD_VERSION}.tar.gz && tar -zxvf /tmp/${UPLOAD_VERSION}.tar.gz -C /tmp \ | ||
&& cd /tmp/nginx-${NGINX_VERSION}\ | ||
&& ./configure \ | ||
--add-module=/tmp/nginx-upload-module-${UPLOAD_VERSION}\ | ||
--with-http_stub_status_module \ | ||
&& make \ | ||
&& make install\ | ||
&& rm -rf /usr/local/nginx/conf | ||
|
||
COPY conf /usr/local/nginx/conf | ||
|
||
EXPOSE 80 | ||
|
||
STOPSIGNAL SIGQUIT | ||
|
||
CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"] |
Oops, something went wrong.