Skip to content

Commit

Permalink
Make dev setup locally usablei
Browse files Browse the repository at this point in the history
  • Loading branch information
FloThinksPi committed Jul 6, 2023
1 parent 10dd141 commit 27e372e
Show file tree
Hide file tree
Showing 33 changed files with 479 additions and 728 deletions.
16 changes: 0 additions & 16 deletions .devcontainer/Dockerfile

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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",
"dockerComposeFile": ["../docker-compose.yml", "docker-compose.override.yml"],
"service": "codespace",
"runServices": [
"postgres",
Expand All @@ -11,9 +11,9 @@
"catsbroker",
"nginx"
],
"workspaceFolder": "..",
"initializeCommand": ".devcontainer/library/initializeCommand.sh",
"onCreateCommand": ".devcontainer/library/onCreateCommand.sh",
"workspaceFolder": "/workspace",
"initializeCommand": ".devcontainer/scripts/codespaces_init.sh",
"onCreateCommand": ".devcontainer/scripts/codespaces_start.sh",
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
Expand Down
19 changes: 19 additions & 0 deletions .devcontainer/docker-compose.override.yml
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
79 changes: 0 additions & 79 deletions .devcontainer/docker-compose.yml

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions .devcontainer/images/devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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
RUN /tmp/setup.sh && rm /tmp/setup.sh
52 changes: 52 additions & 0 deletions .devcontainer/images/devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
set -Eeuo pipefail
# shellcheck disable=SC2064
trap "pkill -P $$" EXIT

setupAptPackages () {

if [[ $(uname -m) == aarch64 ]]; then
PACKAGES="postgresql-client postgresql-client-common mariadb-client docker-compose-plugin"
else
PACKAGES="cf8-cli postgresql-client postgresql-client-common mariadb-client docker-compose-plugin"
fi

install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
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
apt-get update && export DEBIAN_FRONTEND=noninteractive
apt-get install -o Dpkg::Options::="--force-overwrite" $PACKAGES -y
}

setupRubyGems () {
gem install cf-uaac
}

setupCredhubCli () {
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 credhub.tar.gz
tar -xzf credhub.tar.gz && rm -f credhub.tar.gz && mv credhub /usr/bin
}

setupUaaCli () {
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
chmod +x /usr/bin/yq
}

setupAptPackages || tee fail &
setupRubyGems || tee fail &
setupCredhubCli || tee fail &
setupUaaCli || tee fail &


# Wait for background jobs and exit 1 if any error happened
# shellcheck disable=SC2046
wait $(jobs -p)
test -f fail && exit 1

trap "" EXIT
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine

RUN apk --no-cache add build-base pcre-dev openssl-dev gzip curl jq zlib-dev \
&& NGINX_VERSION=$(curl -s https://hub.docker.com/v2/repositories/library/nginx/tags | jq -r ".results[] | select(.images | any(.digest==\"$(curl -s https://hub.docker.com/v2/repositories/library/nginx/tags | jq -r '.results[] | select(.name=="stable").images[] | select(.architecture=="amd64").digest')\")) | .name " | grep "[0-9]*\.[0-9]*\.[0-9]") \
&& 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 \
Expand All @@ -10,7 +10,10 @@ RUN apk --no-cache add build-base pcre-dev openssl-dev gzip curl jq zlib-dev \
--add-module=/tmp/nginx-upload-module-${UPLOAD_VERSION}\
--with-http_stub_status_module \
&& make \
&& make install
&& make install\
&& rm -rf /usr/local/nginx/conf

COPY conf /usr/local/nginx/conf

EXPOSE 80

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ http {
##

upstream cloud_controller {
server unix:/tmp/cloud_controller.sock;
server host.docker.internal:3000;
}

include nginx_external_endpoints.conf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /uaa

# Patch admin client, add authority password.write
COPY PatchAdminOAuthClient.java /PatchAdminOAuthClient.java
RUN apt-get update && apt-get install jq -y \
RUN apt-get update && apt-get install jq -y \
&& git clone -b $(curl -s https://api.github.com/repos/cloudfoundry/uaa/releases/latest | jq -r '.tag_name') https://github.com/cloudfoundry/uaa.git . --recursive --depth=1 --shallow-submodules \
&& git clone -b $(curl -s https://api.github.com/repos/pivotal/credhub-release/releases/latest | jq -r '.tag_name') https://github.com/pivotal/credhub-release /credhub-release --recursive --depth=1 --shallow-submodules \
&& javac /PatchAdminOAuthClient.java -d / \
Expand All @@ -27,7 +27,7 @@ COPY --from=builder /credhub-release/src/credhub/config/uaa.yml /credhub-uaa.yml
# Remove jwt node with symmetric key
# Replace UAA client name in credhub config
# Concatenate modified cargo and credhub config files
RUN yq e '.issuer.uri = "http://localhost:8080"' -i /uaa.yml \
RUN yq e '.issuer.uri = "http://localhost:8080"' -i /uaa.yml \
&& yq e '.uaa.url = .issuer.uri' -i /uaa.yml \
&& yq e 'del(.jwt)' -i /uaa.yml \
&& yq e '.oauth.clients.director_to_credhub = .oauth.clients.credhub_client' -i /credhub-uaa.yml \
Expand All @@ -41,7 +41,7 @@ FROM tomcat:9-jdk11
COPY --from=yq /uaa.yml /uaa.yml

# Remove pre-installed apps
RUN rm -rf /usr/local/tomcat/webapps/*
RUN rm -rf /usr/local/tomcat/webapps/*

# Install war from build image
COPY --from=builder /uaa/uaa/build/libs/cloudfoundry-identity-uaa-*.war /usr/local/tomcat/webapps/ROOT.war
Expand Down
8 changes: 0 additions & 8 deletions .devcontainer/library/idea/.idea/.gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions .devcontainer/library/idea/.idea/libraries/app_packager_zips.xml

This file was deleted.

Loading

0 comments on commit 27e372e

Please sign in to comment.