Skip to content

Commit d0ede5a

Browse files
Merged in Main
2 parents daf0eff + ca71571 commit d0ede5a

94 files changed

Lines changed: 2822 additions & 904 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/.dockerignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Devcontainer specific ignores
2+
.DS_Store
3+
*.log
4+
5+
# Chef's local files (will be copied during build)
6+
chefs_local/local.json
7+
chefs_local/test.json
8+
9+
# Temporary files
10+
*.tmp
11+
*.temp
12+
13+
# IDE files
14+
.vscode/
15+
.idea/
16+
17+
# OS files
18+
.DS_Store
19+
.DS_Store?
20+
._*
21+
.Spotlight-V100
22+
.Trashes
23+
ehthumbs.db
24+
Thumbs.db

.devcontainer/Dockerfile

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
ARG VARIANT="20.18.3-bookworm"
22
FROM node:${VARIANT}
33

4-
# Install some extras such as vim for interactive rebases. Also some
5-
# Cypress prerequisites for running in Debian containers:
6-
# https://docs.cypress.io/app/get-started/install-cypress#UbuntuDebian
7-
# and we set up k6 for performance testing
8-
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69 && \
9-
echo "deb https://dl.k6.io/deb stable main" | tee /etc/apt/sources.list.d/k6.list && \
10-
apt-get update && \
4+
# Layer 1: Install basic system utilities (rarely change)
5+
RUN apt-get update && \
116
DEBIAN_FRONTEND=noninteractive apt-get install -y \
12-
k6 \
13-
libasound2 \
14-
libgbm-dev \
15-
libgtk-3-0 \
16-
libgtk2.0-0 \
17-
libnotify-dev \
18-
libnss3 \
19-
libxss1 \
20-
libxtst6 \
217
vim \
228
xauth \
239
xvfb \
10+
wget \
2411
&& apt-get clean
12+
13+
# Layer 2: Install k6 for performance testing (changes occasionally)
14+
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69 && \
15+
echo "deb https://dl.k6.io/deb stable main" | tee /etc/apt/sources.list.d/k6.list && \
16+
apt-get update && \
17+
DEBIAN_FRONTEND=noninteractive apt-get install -y k6 && \
18+
apt-get clean
19+
20+
# Layer 3: Install Cypress dependencies (changes with Cypress updates)
21+
RUN apt-get update && \
22+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
23+
libasound2 \
24+
libgbm-dev \
25+
libgtk-3-0 \
26+
libnss3 \
27+
libxss1 \
28+
libxtst6 \
29+
&& apt-get clean
30+
31+
# Layer 4: Install Java for SonarLint (changes with project dependencies)
32+
RUN apt-get update && \
33+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
34+
openjdk-17-jre-headless \
35+
&& apt-get clean
36+
37+
# Layer 5: Install global npm packages (changes with project dependencies)
38+
RUN npm install -g knex jest dotenv-cli
39+
40+
# Layer 6: Ensure devcontainer scripts are executable (will be set during container startup)

.devcontainer/devcontainer.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
},
99

1010
"features": {
11-
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
11+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
12+
"ghcr.io/devcontainers/features/git:1": {}
13+
1214
},
1315

1416
// Use this environment variable if you need to bind mount your local source code into a new container.
@@ -28,7 +30,7 @@
2830
],
2931

3032
// Use 'postCreateCommand' to run commands after the container is created.
31-
"postCreateCommand": "bash ./.devcontainer/post-install.sh",
33+
"postCreateCommand": "chmod +x ./.devcontainer/*.sh && bash ./.devcontainer/post-install.sh",
3234

3335
// Configure tool-specific properties.
3436
"customizations": {
@@ -46,7 +48,11 @@
4648
"settings": {
4749
"database-client.telemetry.usesOnlineServices": false,
4850
"editor.defaultFormatter": "esbenp.prettier-vscode",
49-
"editor.formatOnSave": true
51+
"editor.formatOnSave": true,
52+
"sonarlint.autoDownload": true,
53+
"sonarlint.ls.javaHome": "/usr/lib/jvm/java-17-openjdk-amd64",
54+
"sonarlint.analysisExcludesStandalone": "**/*.{c,cpp,h,hpp,cc,cxx}"
55+
5056
}
5157
}
5258
},
@@ -79,5 +85,7 @@
7985
"64120": {
8086
"label": "Sonarlint IDE"
8187
}
82-
}
88+
},
89+
"mounts": ["source=npm-cache,target=/root/.npm,type=volume"]
90+
8391
}

.devcontainer/install-cypress.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Interactive Cypress installation script with explicit paths
4+
echo "🤔 Checking for Cypress setup..."
5+
6+
# Define explicit paths - handle running from .devcontainer directory
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
WORKSPACE_ROOT="${WORKSPACE_ROOT:-$(dirname "${SCRIPT_DIR}")}"
9+
CYPRESS_DIR="${WORKSPACE_ROOT}/tests/functional/cypress"
10+
PACKAGE_JSON="${CYPRESS_DIR}/package.json"
11+
12+
echo "📍 Script directory: ${SCRIPT_DIR}"
13+
echo "📍 Workspace root: ${WORKSPACE_ROOT}"
14+
echo "📍 Cypress directory: ${CYPRESS_DIR}"
15+
16+
if [ -f "${PACKAGE_JSON}" ]; then
17+
echo "📦 Found package.json in ${CYPRESS_DIR}"
18+
read -p "Install Cypress? (y/n): " -n 1 -r
19+
echo ""
20+
21+
if [[ $REPLY =~ ^[Yy]$ ]]; then
22+
echo "📦 Installing Cypress in ${CYPRESS_DIR}..."
23+
cd "${CYPRESS_DIR}"
24+
if npm ci; then
25+
echo "✅ Cypress installed successfully!"
26+
echo "📍 Installation location: ${CYPRESS_DIR}"
27+
else
28+
echo "❌ Cypress installation failed"
29+
exit 1
30+
fi
31+
else
32+
echo "⏭️ Skipped Cypress installation"
33+
fi
34+
else
35+
echo "❌ package.json not found at ${PACKAGE_JSON}"
36+
echo "💡 Expected location: ${CYPRESS_DIR}/package.json"
37+
echo "💡 Current working directory: $(pwd)"
38+
exit 1
39+
fi

.devcontainer/post-install.sh

100644100755
Lines changed: 109 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,131 @@
11
#!/bin/bash
2-
set -ex
2+
set -e
3+
4+
# Function to handle errors
5+
error_handler() {
6+
echo "❌ Error occurred in line $1"
7+
exit 1
8+
}
9+
10+
# Set error handler
11+
trap 'error_handler $LINENO' ERR
312

413
# Convenience workspace directory for later use
514
WORKSPACE_DIR=$(pwd)
615
CHEFS_LOCAL_DIR=${WORKSPACE_DIR}/.devcontainer/chefs_local
16+
# Note: Global npm packages (knex, jest, dotenv-cli) are now installed in Dockerfile
17+
18+
# Ensure we're in the workspace root
19+
cd ${WORKSPACE_DIR}
20+
echo "📍 Working directory: $(pwd)"
21+
22+
# Check if Docker is available
23+
if ! command -v docker &> /dev/null; then
24+
echo "❌ Error: Docker is not available"
25+
exit 1
26+
fi
27+
28+
# Check if Docker Compose is available
29+
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
30+
echo "❌ Error: Docker Compose is not available"
31+
exit 1
32+
fi
33+
34+
# Check if required directories exist
35+
if [ ! -d "components" ]; then
36+
echo "❌ Error: components directory not found"
37+
exit 1
38+
fi
39+
40+
if [ ! -d "app" ]; then
41+
echo "❌ Error: app directory not found"
42+
exit 1
43+
fi
44+
45+
if [ ! -d "app/frontend" ]; then
46+
echo "❌ Error: app/frontend directory not found"
47+
exit 1
48+
fi
49+
50+
# install dependencies in parallel for faster setup
51+
echo "📦 Installing dependencies in parallel..."
752

8-
npm install knex -g
9-
npm install jest -g
10-
npm install dotenv-cli -g
53+
# Install components dependencies
54+
(cd components && npm install) &
55+
COMPONENTS_PID=$!
1156

12-
# install components/formio libraries, prepare for ux development and debugging...
13-
cd components
14-
npm install
57+
# Install app dependencies
58+
(cd app && npm install) &
59+
APP_PID=$!
1560

16-
# install app libraries, prepare for app development and debugging...
17-
cd ../app
18-
npm install
61+
# Install frontend dependencies
62+
(cd app/frontend && npm install) &
63+
FRONTEND_PID=$!
1964

20-
# install frontend libraries, prepare for ux development and debugging...
21-
cd frontend
22-
npm install
65+
# Wait for all installations to complete
66+
wait $COMPONENTS_PID $APP_PID $FRONTEND_PID
67+
68+
# Check if any installations failed
69+
if [ $? -ne 0 ]; then
70+
echo "❌ Error: One or more npm installations failed"
71+
exit 1
72+
fi
73+
74+
echo "✅ All dependencies installed successfully!"
2375

2476
# make an initial build of formio components and ready them for frontend
77+
cd ${WORKSPACE_DIR}/app/frontend
2578
npm run build:formio
2679
npm run deploy:formio
2780

2881
# copy over the sample files to the image...
29-
cp -u ${CHEFS_LOCAL_DIR}/local.sample.json ${CHEFS_LOCAL_DIR}/local.json
82+
if [ ! -f "${CHEFS_LOCAL_DIR}/local.json" ]; then
83+
cp ${CHEFS_LOCAL_DIR}/local.sample.json ${CHEFS_LOCAL_DIR}/local.json
84+
fi
3085

3186
# fire up postgres... we want to seed the db
32-
docker compose -f ${CHEFS_LOCAL_DIR}/docker-compose.yml up --wait
87+
echo "🐘 Starting PostgreSQL..."
88+
if ! docker compose -f ${CHEFS_LOCAL_DIR}/docker-compose.yml up postgres -d; then
89+
echo "❌ Failed to start PostgreSQL"
90+
exit 1
91+
fi
92+
93+
# Wait for PostgreSQL to be ready
94+
echo "⏳ Waiting for PostgreSQL to be ready..."
95+
max_attempts=30
96+
attempt=1
97+
while [ $attempt -le $max_attempts ]; do
98+
if docker compose -f ${CHEFS_LOCAL_DIR}/docker-compose.yml exec -T postgres pg_isready -U app -d chefs > /dev/null 2>&1; then
99+
echo "✅ PostgreSQL is ready!"
100+
break
101+
fi
102+
echo "⏳ Attempt $attempt/$max_attempts: PostgreSQL not ready yet..."
103+
sleep 2
104+
attempt=$((attempt + 1))
105+
done
106+
107+
if [ $attempt -gt $max_attempts ]; then
108+
echo "❌ PostgreSQL failed to start within expected time"
109+
exit 1
110+
fi
111+
33112
# run an initial migration for the db and seed it...
34113
export NODE_CONFIG_DIR=${CHEFS_LOCAL_DIR} # need this to connect to the running postgres instance.
35-
cd .. # back to app dir
36-
npm run migrate
114+
cd ${WORKSPACE_DIR}/app # ensure we're in the app directory
115+
echo "🗄️ Running database migrations..."
116+
if ! npm run migrate; then
117+
echo "❌ Failed to run database migrations"
118+
exit 1
119+
fi
37120
# npm run seed:run
38121

39-
# install cypress libraries
40-
cd ../tests/functional/cypress
41-
npm ci
42-
43122
# take down postgres, do not need them running all the time.
44-
docker compose -f ${CHEFS_LOCAL_DIR}/docker-compose.yml down
123+
echo "🛑 Stopping PostgreSQL..."
124+
if ! docker compose -f ${CHEFS_LOCAL_DIR}/docker-compose.yml down; then
125+
echo "⚠️ Warning: Failed to stop PostgreSQL containers"
126+
fi
127+
128+
# Note: Cypress installation is now handled via VS Code tasks
129+
# Run Task -> Install Cypress
130+
# Run Task -> Run Cypress Tests (Interactive)
131+

0 commit comments

Comments
 (0)