Skip to content

Commit 40ddd8d

Browse files
committed
Fix devcontainer
1 parent f95c1d9 commit 40ddd8d

File tree

11 files changed

+350
-237
lines changed

11 files changed

+350
-237
lines changed

.devcontainer/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Cloud Controller Development Environment
2+
3+
This document outlines how to set up and use the development environment for the Cloud Controller.
4+
5+
## Getting Started
6+
7+
1. **Prerequisites**: Ensure you have Docker and Visual Studio Code with the "Remote - Containers" extension installed.
8+
2. **Launch the Environment**:
9+
* Open the `cloud_controller_ng` project folder in VS Code.
10+
* When prompted, click **"Reopen in Container"**. This will build the Docker images and start the development container. Also you can use the command palette (`Ctrl+Shift+P` or `Cmd+Shift+P` on macOS) and select **"Dev Containers: Reopen in Container"** or go to the remote explorer and select **"Reopen in Container"**.
11+
* The initial build may take some time as it installs all dependencies.
12+
13+
## Interacting with the Environment
14+
15+
Once the container is running, the startup script (`.devcontainer/scripts/codespaces_start.sh`) will automatically:
16+
17+
* Set up and seed the PostgreSQL and MariaDB databases.
18+
* Configure the Cloud Controller application.
19+
* Start all necessary services (UAA, Minio, Nginx, etc.).
20+
21+
## VS Code Launch Configurations
22+
23+
The `.vscode/launch.json` file contains several configurations for running and debugging different components of the Cloud Controller. You can access these from the "Run and Debug" panel in VS Code.
24+
25+
### Main Application
26+
27+
* **`[Postgres] CloudController`**: Runs the main Cloud Controller API using PostgreSQL as the database.
28+
* **`[Mariadb] CloudController`**: Runs the main Cloud Controller API using MariaDB as the database.
29+
30+
> Note only one can be run at a time. Ensure the other is stopped before starting a new one.
31+
32+
### Workers & Scheduler
33+
34+
* **`[Postgres/Mariadb] CC Worker`**: Starts the generic background job worker against the respective database.
35+
* **`[Postgres/Mariadb] CC Local Worker`**: Starts the local background job worker against the respective database.
36+
* **`[Postgres/Mariadb] CC Scheduler`**: Starts the clock process for scheduling recurring tasks against the respective database.
37+
38+
> Note only one can be run at a time either against Postgres or Mysql. Ensure the other is stopped before starting a new one.
39+
40+
### Testing
41+
42+
* **`[Postgres/Mariadb] Unittests`**: Runs the complete RSpec test suite against the specified database.
43+
44+
### Cloud Foundry CLI
45+
46+
The environment comes pre-installed with the `cf8-cli` and `uaac`. You can interact with the local Cloud Foundry deployment from the VS Code terminal.
47+
48+
**API Endpoint**: `http://localhost:80`
49+
50+
**Admin Credentials**:
51+
52+
* **Username**: `ccadmin`
53+
* **Password**: `secret`
54+
55+
**Example Login Workflow**:
56+
57+
1. **Target the API**:
58+
59+
```bash
60+
cf api http://localhost:80 --skip-ssl-validation
61+
```
62+
63+
2. **Log In**:
64+
65+
```bash
66+
cf auth ccadmin secret
67+
```
68+
69+
### PostgreSQL and MariaDB Access
70+
71+
You can connect directly to the databases running in the environment from the VS Code terminal.
72+
73+
#### PostgreSQL
74+
75+
* **Host**: `localhost`
76+
* **Port**: `5432`
77+
* **User**: `postgres`
78+
* **Password**: `supersecret`
79+
80+
**Example Connection**:
81+
82+
```bash
83+
PGPASSWORD=supersecret psql -h localhost -U postgres -d ccdb
84+
```
85+
86+
#### MariaDB (MySQL)
87+
88+
* **Host**: `127.0.0.1`
89+
* **Port**: `3306`
90+
* **User**: `root`
91+
* **Password**: `supersecret`
92+
93+
**Example Connection**:
94+
95+
```bash
96+
mysql -h 127.0.0.1 -u root -psupersecret ccdb
97+
```

.devcontainer/devcontainer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
"nginx"
2121
],
2222
"workspaceFolder": "/workspace",
23-
"initializeCommand": ".devcontainer/scripts/codespaces_init.sh",
24-
"onCreateCommand": ".devcontainer/scripts/codespaces_start.sh",
23+
"onCreateCommand": "bash .devcontainer/scripts/codespaces_start.sh",
2524
"customizations": {
2625
// Configure properties specific to VS Code.
2726
"vscode": {

.devcontainer/docker-compose.override.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3.3"
21
services:
32

43
# Dev Container
@@ -8,7 +7,6 @@ services:
87
context: ./
98
dockerfile: .devcontainer/images/devcontainer/Dockerfile
109
restart: unless-stopped
11-
command: /bin/sh -c "while sleep 1000; do :; done"
1210
volumes:
1311
- .:/workspace:cached
1412
- /var/run/docker.sock:/var/run/docker.sock
@@ -17,3 +15,4 @@ services:
1715
- SYS_PTRACE
1816
security_opt:
1917
- seccomp:unconfined
18+
privileged: true

.devcontainer/images/bbs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM golang:1
22

3-
RUN apt update && apt install -y jq && git clone --recurse-submodules -b $(curl -s https://api.github.com/repos/cloudfoundry/diego-release/releases/latest | jq -r '.tag_name') https://github.com/cloudfoundry/diego-release && cd ./diego-release/src/code.cloudfoundry.org && \
3+
RUN apt update && git clone --recurse-submodules -b v2.118.0 https://github.com/cloudfoundry/diego-release && cd ./diego-release/src/code.cloudfoundry.org && \
44
CG_ENABLED=0 go install code.cloudfoundry.org/locket/cmd/locket && \
55
CG_ENABLED=0 go install code.cloudfoundry.org/bbs/cmd/bbs
66
VOLUME /bbs
Lines changed: 127 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,129 @@
1-
FROM mcr.microsoft.com/vscode/devcontainers/ruby:3.2
1+
FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04
2+
3+
4+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
5+
6+
# Set environment variables for Ruby development
7+
ENV BUNDLE_PATH=/home/vscode/.bundle
8+
ENV GEM_HOME=/home/vscode/.gem
9+
ENV GEM_PATH=/home/vscode/.gem
10+
ENV RAILS_ENV=development
11+
ENV RACK_ENV=development
12+
13+
# Install system dependencies for Ruby development
14+
RUN wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | gpg --dearmor -o /usr/share/keyrings/cli.cloudfoundry.org.gpg && \
15+
echo "deb [signed-by=/usr/share/keyrings/cli.cloudfoundry.org.gpg] https://packages.cloudfoundry.org/debian stable main" > /etc/apt/sources.list.d/cloudfoundry-cli.list && \
16+
apt-get update && \
17+
apt-get install -y \
18+
# CF CLI
19+
cf8-cli \
20+
# Build tools
21+
build-essential \
22+
autoconf \
23+
bison \
24+
patch \
25+
# Ruby dependencies
26+
libssl-dev \
27+
libreadline-dev \
28+
zlib1g-dev \
29+
libncurses5-dev \
30+
libffi-dev \
31+
libgdbm-dev \
32+
libyaml-dev \
33+
libsqlite3-dev \
34+
sqlite3 \
35+
libgmp-dev \
36+
libgdbm6 \
37+
libdb-dev \
38+
uuid-dev \
39+
# Database clients
40+
postgresql-client \
41+
postgresql-client-common \
42+
mysql-client \
43+
redis-tools \
44+
# Database development headers
45+
libpq-dev \
46+
default-libmysqlclient-dev \
47+
# Development tools
48+
curl \
49+
wget \
50+
git \
51+
vim \
52+
nano \
53+
htop \
54+
tree \
55+
jq \
56+
unzip \
57+
zip \
58+
# Network tools
59+
netcat-openbsd \
60+
# XML/HTML processing
61+
libxml2-dev \
62+
libxslt1-dev \
63+
# GPG for RVM
64+
gnupg2 \
65+
# Additional utilities
66+
tmux \
67+
screen \
68+
less \
69+
man-db \
70+
&& rm -rf /var/lib/apt/lists/*
71+
72+
# Install yq v4 for the correct architecture
73+
RUN YQ_ARCH=$(uname -m) && \
74+
case $YQ_ARCH in \
75+
x86_64) YQ_ARCH="amd64";; \
76+
aarch64) YQ_ARCH="arm64";; \
77+
esac && \
78+
wget "https://github.com/mikefarah/yq/releases/download/v4.47.1/yq_linux_${YQ_ARCH}" -O /usr/local/bin/yq && \
79+
chmod +x /usr/local/bin/yq
80+
281

3-
COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/
4-
COPY .devcontainer/images/devcontainer/setup.sh /tmp/setup.sh
5-
COPY .ruby-version /tmp/.ruby-version
682
USER vscode
7-
RUN /tmp/setup.sh && sudo rm /tmp/setup.sh /tmp/.ruby-version
83+
84+
# Create necessary directories and set permissions
85+
RUN mkdir -p $BUNDLE_PATH $GEM_HOME && chown -R vscode:vscode $BUNDLE_PATH $GEM_HOME
86+
87+
# Install GPG keys for RVM
88+
RUN gpg2 --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
89+
90+
# Install RVM
91+
RUN curl -sSL https://get.rvm.io | bash -s stable --path /home/vscode/.rvm
92+
93+
# Copy Ruby version file for reference
94+
COPY .ruby-version /tmp/ruby-version
95+
96+
# Install Ruby using RVM with binary packages when available, fallback to parallel source compilation
97+
RUN /bin/bash -l -c "source /home/vscode/.rvm/scripts/rvm && \
98+
export rvm_make_opts=\"-j$(nproc)\" && \
99+
export RUBY_CONFIGURE_OPTS=\"--disable-install-doc\" && \
100+
rvm install $(cat /tmp/ruby-version) && \
101+
rvm use $(cat /tmp/ruby-version) --default && \
102+
gem install bundler"
103+
104+
# Configure Bundler and install cf-uaac as vscode user
105+
RUN /bin/bash -l -c "source /home/vscode/.rvm/scripts/rvm && \
106+
bundle config set --global path \"$BUNDLE_PATH\" && \
107+
bundle config set --global jobs $(nproc) && \
108+
bundle config set --global specific_platform true && \
109+
gem install cf-uaac"
110+
111+
# Configure Git
112+
RUN git config --global core.fileMode false
113+
114+
# Source RVM and configure shell
115+
RUN echo 'export BUNDLE_PATH="$BUNDLE_PATH"' >> /home/vscode/.bashrc \
116+
&& echo 'export GEM_HOME="$GEM_HOME"' >> /home/vscode/.bashrc \
117+
&& echo 'export GEM_PATH="$GEM_PATH"' >> /home/vscode/.bashrc \
118+
&& echo 'source /home/vscode/.rvm/scripts/rvm' >> /home/vscode/.bashrc
119+
120+
# Configure Git (useful defaults)
121+
RUN git config --global init.defaultBranch main \
122+
&& git config --global pull.rebase false \
123+
&& git config --global core.autocrlf input
124+
125+
# Set working directory
126+
WORKDIR /workspace
127+
USER root
128+
# Sleep forever to keep the container running
129+
CMD ["tail", "-f", "/dev/null"]

.devcontainer/images/devcontainer/setup.sh

Lines changed: 0 additions & 59 deletions
This file was deleted.

.devcontainer/scripts/codespaces_init.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)