Skip to content

Commit

Permalink
Merge pull request #116 from linkorb/improve-devcontainer-local-setup…
Browse files Browse the repository at this point in the history
…-0000

Improve devcontainer local setup #0000
  • Loading branch information
mhitza authored Jan 8, 2025
2 parents c50ca9a + 0c58532 commit 11999b4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 6 additions & 0 deletions templates/.devcontainer/devcontainer.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
"description": "Packagist access token, required for installation of composer packages from private packagist",
"documentationUrl": "https://packagist.com/orgs/linkorb"
}
{% endif %}
},
"remoteEnv": {
{% if repo.devcontainer.private_packagist and (repo.type in ['application', 'library', 'symfony-bundle'] or repo.type.startswith('php-')) %}
"GITHUB_USER_ON_HOST": "${localEnv:GITHUB_USER}",
"PACKAGIST_TOKEN_ON_HOST": "${localEnv:PACKAGIST_TOKEN}"
{% endif %}
},
"postCreateCommand": ".devcontainer/postCreate.sh",
Expand Down
7 changes: 2 additions & 5 deletions templates/.devcontainer/postCreate.sh.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/usr/bin/env bash
# {{ repo_managed }}

# Workaround for recent Python versions which prevent global pip package installation without an explicit flag
# or removal of a certain file.
sudo rm /usr/lib/python3.*/EXTERNALLY-MANAGED || true

# This is a workaround on an issue with the devcontainer reported on Windows where followup git config commands would
# fail. #9067
git config --global --add safe.directory /app
Expand All @@ -14,7 +10,8 @@ git config commit.template .devcontainer/git/linkorb_commit.template
{% if repo.type in ['application', 'library', 'symfony-bundle'] or repo.type.startswith('php-') %}

{% if repo.devcontainer.private_packagist %}
composer config --global --auth http-basic.repo.packagist.com "$GITHUB_USER" "$PACKAGIST_TOKEN"
composer config --global --auth http-basic.repo.packagist.com \
"${GITHUB_USER:-$GITHUB_USER_ON_HOST}" "${PACKAGIST_TOKEN:-$PACKAGIST_TOKEN_ON_HOST}"
{% endif %}

composer install
Expand Down
7 changes: 0 additions & 7 deletions templates/.devcontainer/postStart.sh.j2
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
#!/usr/bin/env bash
# {{ repo_managed }}

# pre-push composer-unused hook disabled. See Card #8980
if [ -f .git/hooks/pre-push ]; then
diff .devcontainer/git/hooks/pre-push .git/hooks/pre-push
if [ $? -eq 0 ]; then
rm .git/hooks/pre-push
fi
fi
{{ repo.devcontainer.postStartCommand|default('') }}

0 comments on commit 11999b4

Please sign in to comment.