-
-
Notifications
You must be signed in to change notification settings - Fork 94
Add Docker Compose setup for local development #383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
a570523
93e051b
e453497
8725cd2
9661f36
39b0ee9
eb3190c
651f976
9720cbb
eaa6216
96523d5
5eba4ae
d44b338
1ab18cd
f4672ae
7745586
7b4bc81
7993560
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| WORKSPACE_ = "/home/jenkins/agent/workspace" | ||
| 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" | ||
|
Eng-Omar-Hussein marked this conversation as resolved.
|
||
| # // Added the below to fix permissions issue with the cache | ||
| GATSBY_CACHE_DIR = "${WORKSPACE_}/.gatsby-cache" | ||
| GATSBY_INTERNAL_CACHE_DIR = "${WORKSPACE_}/.cache" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will break the CI. Is it needed with Docker Compose?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not needed in Docker. I initially thought it was important to fix permissions in the CI, so I kept it in Docker. However, after testing, I found a problem that may occur if the user runs it on the host OS using the default user with UID=1000. They will face an error related to cache permissions, because the Jenkins user used in Docker Compose has UID=1001. As a result, the bind-mounted data will have 1000 ownership, and Jenkins will not have permission to write to these files. Therefore, I should add this to the documentation. For example: Before running docker compose up, make sure that the user you are using has UID=1001. If not, use the command below. or create and use a user with UID=1001
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is not a safe neither a portable solution:
Since there are no reason to share the cache dir with the host, WDYT about setting the env. var in Docker Compose only, to a container-internal directory.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue is that Gatsby is ignoring I recently reach to solution:
services:
fix-permissions:
image: busybox
user: root
working_dir: /app
volumes:
- .:/app
command: >
sh -c "
if ! [ -d /app/public ]; then
mkdir -p /app/public
fi
if ! [ -d /app/.cache ]; then
mkdir -p /app/.cache
fi
if ! id -u jenkins > /dev/null 2>&1; then
adduser -u 1001 -D jenkins
fi
chown -R jenkins:jenkins /app/public /app/.cache
"
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new version of this recommended solution replace fix-permissions:
image: busybox
user: root
working_dir: /app
volumes:
- .:/app
command: >
sh -c "
dirs='public .cache node_modules'
for d in $$dirs; do
mkdir -p $$d
chmod -R 777 $$d
done
chmod 666 package-lock.json
"
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Removing the I am pleased to share with you a demonstration to show the behavior if
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see. Any reason to mount
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah exactly, Mounting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good, then let's roll with mounting
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done, this video shows that the Video.Project.3.mp4 |
||
| GATSBY_TELEMETRY_DISABLED = "1" | ||
| NODE_OPTIONS = "--no-warnings" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| 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.91.1 | ||
|
|
||
| ports: | ||
| - "8000:8000" | ||
|
|
||
| # Load environment variables | ||
| env_file: | ||
| - .env | ||
| # Add docker-compose-specific env vars | ||
| environment: | ||
| CHOKIDAR_USEPOLLING: "true" | ||
| PATH: /home/jenkins/.asdf/shims:/home/jenkins/.asdf/bin:$PATH | ||
| NODE_ENV: development | ||
|
|
||
| volumes: | ||
| - .:${WORKSPACE_} | ||
|
|
||
| working_dir: ${WORKSPACE_} | ||
|
|
||
| user: jenkins | ||
|
|
||
| entrypoint: [] | ||
| command: bash -c "asdf install && asdf current && npm install && npm run develop" | ||
|
|
||
| networks: | ||
| - stories_network | ||
|
|
||
| networks: | ||
| stories_network: | ||
| driver: bridge | ||
|
Eng-Omar-Hussein marked this conversation as resolved.
Outdated
|
||

Uh oh!
There was an error while loading. Please reload this page.