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 2e752e9
Show file tree
Hide file tree
Showing 35 changed files with 501 additions and 732 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.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"env": {
"DB": "postgres",
"DB_CONNECTION_STRING": "postgres://postgres:supersecret@postgres:5432/ccdb"
"DB_CONNECTION_STRING": "postgres://postgres:supersecret@localhost:5432/ccdb"
}
},
{
Expand All @@ -33,7 +33,7 @@
],
"env": {
"DB": "mysql",
"DB_CONNECTION_STRING": "mysql2://root:supersecret@mariadb:3306/ccdb"
"DB_CONNECTION_STRING": "mysql2://root:supersecret@localhost:3306/ccdb"
}
}
]
Expand Down
10 changes: 5 additions & 5 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 All @@ -31,5 +31,5 @@
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": []
"forwardPorts": [80,1234,9292,9393,9000,9001,8080,3306,5432]
}
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.
6 changes: 6 additions & 0 deletions .devcontainer/images/devcontainer/Dockerfile
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
49 changes: 49 additions & 0 deletions .devcontainer/images/devcontainer/setup.sh
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
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.

Loading

0 comments on commit 2e752e9

Please sign in to comment.