Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a570523
feat: add Docker Compose setup for local development
Eng-Omar-Hussein Mar 30, 2026
93e051b
Modify command for stories_webapp service
Eng-Omar-Hussein Mar 30, 2026
e453497
Refactor docker-compose.yml structure
Eng-Omar-Hussein Mar 30, 2026
8725cd2
Modify docker-compose.yml for workspace variable usage
Eng-Omar-Hussein Mar 30, 2026
9661f36
refactor: streamline Jenkinsfile stages and improve deployment logic
Eng-Omar-Hussein Apr 4, 2026
39b0ee9
Refactor Jenkinsfile
Eng-Omar-Hussein Apr 4, 2026
eb3190c
Apply suggestions from code review
Eng-Omar-Hussein Apr 7, 2026
651f976
refactor: update environment variable handling in Jenkinsfile and doc…
Eng-Omar-Hussein Apr 7, 2026
9720cbb
docs: update Docker Compose usage instructions for user ID requirement
Eng-Omar-Hussein Apr 7, 2026
eaa6216
Merge branch 'jenkins-infra:main' into compose
Eng-Omar-Hussein Apr 7, 2026
96523d5
Merge branch 'compose' of github.com:Eng-Omar-Hussein/stories into co…
Eng-Omar-Hussein Apr 7, 2026
5eba4ae
Merge branch 'compose' of github.com:Eng-Omar-Hussein/stories into co…
Eng-Omar-Hussein Apr 7, 2026
d44b338
refactor: streamline Jenkinsfile and enhance Docker Compose setup for…
Eng-Omar-Hussein Apr 11, 2026
1ab18cd
refactor: simplify directory creation and permissions in Docker Compo…
Eng-Omar-Hussein Apr 12, 2026
f4672ae
refactor: update working directory in .env and optimize Docker Compos…
Eng-Omar-Hussein Apr 13, 2026
7745586
Merge branch 'main' into compose
Eng-Omar-Hussein May 13, 2026
7b4bc81
fix: update jenkins agent image version
Eng-Omar-Hussein May 13, 2026
7993560
Merge branch 'main' into compose
krisstern Jun 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
APP_WORKING_DIR = "/home/jenkins/agent"
NODE_ENV = 'production'
TZ = "UTC"
# // Amount of available vCPUs, to avoid OOM - https://www.gatsbyjs.com/docs/how-to/performance/resolving-out-of-memory-issues/#try-reducing-the-number-of-cores
# // https://github.com/jenkins-infra/jenkins-infra/tree/production/hieradata/clients/controller.ci.jenkins.io.yaml#L327
GATSBY_CPU_COUNT = "4"
Comment thread
Eng-Omar-Hussein marked this conversation as resolved.
GATSBY_TELEMETRY_DISABLED = "1"
NODE_OPTIONS = "--no-warnings"
189 changes: 105 additions & 84 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,96 +10,114 @@ pipeline {
label 'linux-arm64-docker || arm64linux'
}

environment {
NODE_ENV = 'production'
TZ = "UTC"
// Amount of available vCPUs, to avoid OOM - https://www.gatsbyjs.com/docs/how-to/performance/resolving-out-of-memory-issues/#try-reducing-the-number-of-cores
// https://github.com/jenkins-infra/jenkins-infra/tree/production/hieradata/clients/controller.ci.jenkins.io.yaml#L327
GATSBY_CPU_COUNT = "4"
// Added the below to fix permissions issue with the cache
GATSBY_CACHE_DIR = "${env.WORKSPACE}/.gatsby-cache"
GATSBY_INTERNAL_CACHE_DIR = "${env.WORKSPACE}/.cache"
GATSBY_TELEMETRY_DISABLED = "1"
NODE_OPTIONS = "--no-warnings"
}

stages {
stage('Check for typos') {
steps {
sh '''
curl -qsL https://github.com/crate-ci/typos/releases/download/v1.33.1/typos-v1.33.1-x86_64-unknown-linux-musl.tar.gz | tar xvzf - ./typos
./typos --format sarif > typos.sarif || true
'''
}
post {
always {
recordIssues(tools: [sarif(id: 'typos', name: 'Typos', pattern: 'typos.sarif')])
}
}
}
stage('Test and build') {
parallel {
stage('Main CI') {
stages {
stage('Check for typos') {
steps {
sh '''
curl - qsL https: //github.com/crate-ci/typos/releases/download/v1.33.1/typos-v1.33.1-x86_64-unknown-linux-musl.tar.gz | tar xvzf - ./typos
. / typos--format sarif > typos.sarif || true
'''
}
post {
always {
recordIssues(tools: [sarif(id: 'typos', name: 'Typos', pattern: 'typos.sarif')])
}
}
}

stage('Check Tooling') {
steps {
sh '''
node --version
npm --version
'''
}
}
stage('Check Tooling') {
steps {
sh '''
node --version
npm --version
'''
}
}

stage('Install Dependencies') {
environment {
NODE_ENV = 'development'
}
steps {
sh 'npm ci'
}
}
stage('Install Dependencies') {
environment {
NODE_ENV = 'development'
}
steps {
sh 'npm ci'
}
}

stage('Lint and Test') {
environment {
NODE_ENV = "development"
}
steps {
sh 'npm run lint && npx eslint --format checkstyle > eslint.xml'
}
post {
always {
recordIssues(tools: [checkStyle(pattern: 'eslint.xml')])
}
}
}
stage('Lint and Test') {
environment {
NODE_ENV = "development"
}
steps {
sh 'npm run lint && npx eslint --format checkstyle > eslint.xml'
}
post {
always {
recordIssues(tools: [checkStyle(pattern: 'eslint.xml')])
}
}
}

stage('Build PR') {
when { changeRequest() }
environment {
NODE_ENV = 'development'
}
steps {
sh 'npm run build'
}
}
stage('Build PR') {
when {
changeRequest()
}
environment {
NODE_ENV = 'development'
}
steps {
sh '''
source ./.env
npm run build
'''
}
}

stage('Deploy PR to preview site') {
when {
allOf{
changeRequest target: 'main'
// Only deploy to production from infra.ci.jenkins.io
expression { infra.isInfra() }
}
}
environment {
NETLIFY_AUTH_TOKEN = credentials('netlify-auth-token')
}
steps {
sh 'netlify-deploy --draft=true --siteName "jenkins-is-the-way" --title "Preview deploy for ${CHANGE_ID}" --alias "deploy-preview-${CHANGE_ID}" -d ./public'
}
post {
success {
recordDeployment('jenkins-infra', 'stories', pullRequest.head, 'success', "https://deploy-preview-${CHANGE_ID}--jenkins-is-the-way.netlify.app")
stage('Deploy PR to preview site') {
when {
allOf {
changeRequest target: 'main'
// Only deploy to production from infra.ci.jenkins.io
expression { infra.isInfra() }
}
}
environment {
NETLIFY_AUTH_TOKEN = credentials('netlify-auth-token')
}
steps {
sh 'netlify-deploy --draft=true --siteName "jenkins-is-the-way" --title "Preview deploy for ${CHANGE_ID}" --alias "deploy-preview-${CHANGE_ID}" -d ./public'
}
post {
success {
recordDeployment('jenkins-infra', 'stories', pullRequest.head, 'success', "https://deploy-preview-${CHANGE_ID}--jenkins-is-the-way.netlify.app")
}
failure {
recordDeployment('jenkins-infra', 'stories', pullRequest.head, 'failure', "https://deploy-preview-${CHANGE_ID}--jenkins-is-the-way.netlify.app")
}
}
}
}
}
failure {
recordDeployment('jenkins-infra', 'stories', pullRequest.head, 'failure', "https://deploy-preview-${CHANGE_ID}--jenkins-is-the-way.netlify.app")

stage('Test Docker Compose') {
when {
allOf {
changeRequest()
// Only run docker tests on non-infra.ci.jenkins.io
expression { !infra.isInfra() }
}
}
steps {
Comment thread
Eng-Omar-Hussein marked this conversation as resolved.
sh '''
source ./.env
docker compose up --detach --wait
docker compose run --rm stories_webapp env
docker compose down
'''
}
}
}
}
Expand All @@ -109,7 +127,10 @@ pipeline {
branch "main"
}
steps {
sh 'npm run build'
sh '''
source ./.env
npm run build
'''
}
}

Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ npm run develop

Open [http://localhost:8000](http://localhost:8000) on your browser to see the result

## Alternative Development Setup: Docker Compose

You can also use Docker Compose for local development.

### How to Use

1. Ensure you have [Docker](https://www.docker.com/products/docker-desktop/) and [Docker Compose](https://docs.docker.com/compose/) installed.
2. In the project **root**, run:
```bash
docker compose up
```
3. Open [http://localhost:8000](http://localhost:8000) in your browser.

> Note: You can override the number of CPUs used by Gatsby by setting the `GATSBY_CPU_COUNT` environment variable to avoid OOM.

## Code Quality Tools

### Formatting
Expand Down
34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
services:
stories_webapp:
# TODO: track version with updatecli - ref. https://github.com/jenkins-infra/jenkins-infra/blob/efe90908529525bb3c9e61c2eb920ada3b968f1a/updatecli/updatecli.d/jenkinscontroller-tools-maven.yaml#L17-L22
image: jenkinsciinfra/jenkins-agent-ubuntu-22.04:2.102.0
ports:
- "8000:8000"

environment:
# Can pass the "GATSBY_CPU_COUNT" from your shell straight through to your containers, if it is set and not empty, otherwise the default value will be used to avoid OOM issues
GATSBY_CPU_COUNT: ${GATSBY_CPU_COUNT:-physical_cores}
CHOKIDAR_USEPOLLING: "true"
NODE_ENV: development
APP_WORKING_DIR: $APP_WORKING_DIR

volumes:
- .:$APP_WORKING_DIR/workspace
- ./src:$APP_WORKING_DIR/src
- stories_node_modules:/tmp/node_modules

working_dir: $APP_WORKING_DIR
user: jenkins
entrypoint: []
command: >
sh -c "
ln -s /tmp/node_modules ${APP_WORKING_DIR}/node_modules || true &&
cp -r ${APP_WORKING_DIR}/workspace/. . || true &&
node --version &&
npm --version &&
npm ci &&
npm run develop -- -H 0.0.0.0 -p 8000
"

volumes:
stories_node_modules: