-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR add godpod.io integration with git gpg support (#81)
- Loading branch information
1 parent
dd16fc8
commit da0221e
Showing
4 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM gitpod/workspace-mysql | ||
|
||
USER root | ||
|
||
# Update APT Database | ||
### base ### | ||
RUN apt-get update -q \ | ||
&& apt-get install -y php-dev | ||
|
||
# Install XDebug | ||
RUN curl -sSf http://xdebug.org/files/xdebug-3.1.3.tgz | tar xz \ | ||
&& cd xdebug-3.1.3 \ | ||
&& phpize \ | ||
&& ./configure \ | ||
&& make install -j$(nproc) \ | ||
&& printf 'zend_extension=xdebug\n[XDebug]\nxdebug.remote_enable=1\nxdebug.remote_autostart=1\n' > /etc/php/7.4/mods-available/xdebug.ini \ | ||
&& ln -sf /etc/php/7.4/mods-available/xdebug.ini "$(php-config --ini-dir)/20-xdebug.ini" | ||
|
||
# Install latest composer v2 release | ||
RUN curl -sSf https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \ | ||
&& mkdir -p /home/gitpod/.config \ | ||
&& chown -R gitpod:gitpod /home/gitpod/.config | ||
|
||
USER gitpod | ||
|
||
# Install Changelogger | ||
RUN composer global require churchtools/changelogger | ||
|
||
# Add Workspace/Project composer bin folder to $PATH | ||
ENV PATH="$PATH:$HOME/.config/composer/vendor/bin:$GITPOD_REPO_ROOT/vendor/bin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
image: | ||
file: .gitpod.Dockerfile | ||
|
||
ports: | ||
- port: 8000 | ||
onOpen: open-browser | ||
- port: 3306 | ||
onOpen: ignore | ||
- port: 33060 | ||
onOpen: ignore | ||
|
||
# List the start up tasks. Learn more https://www.gitpod.io/docs/config-start-tasks/ | ||
tasks: | ||
- before: bash .gp/bash/before-tasks.sh | ||
init: | | ||
composer install -o -n | ||
name: Main Terminal | ||
|
||
vscode: | ||
extensions: | ||
- felixfbecker.php-debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/bash | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# Copyright © 2021 Apolo Pena | ||
# | ||
# before-tasks.sh | ||
# Description: | ||
# Tasks that should be run every time the workspace is created or started. | ||
# | ||
# Notes: | ||
# Gitpod currently does not persist files in the home directory so we must write them | ||
# in everytime the workspace starts. This is done in the 'before' task in .gitpod.yml | ||
|
||
# BEGIN: Enable GPG key to sign Git commits. | ||
# Error handling for improper use of GPG environment variables | ||
err_msg_prefix1="A GPG_KEY was found but it's corresponding GPG_KEY_ID was not." | ||
err_msg_prefix2="A GPG_KEY_ID was found but it's corresponding GPG_KEY was not." | ||
err_msg_suffix="Git commits will not be signed." | ||
[[ -n $GPG_KEY && -z $GPG_KEY_ID ]] && | ||
echo "ERROR: $err_msg_prefix1 $err_msg_suffix" | ||
[[ -n $GPG_KEY_ID && -z $GPG_KEY ]] && | ||
echo "ERROR: $err_msg_prefix2 $err_msg_suffix" | ||
# Main GPG key logic | ||
if [[ -n $GPG_KEY && -n $GPG_KEY_ID ]]; then | ||
gpg_conf_path=~/.gnupg/gpg.conf | ||
msg="Enabling Git commit signing for GPG key id: $GPG_KEY_ID" | ||
gpg -q --batch --import <(echo "$GPG_KEY" | base64 -d) && | ||
echo 'pinentry-mode loopback' >> "$gpg_conf_path" && | ||
git config --global user.signingkey "$GPG_KEY_ID" && | ||
git config commit.gpgsign true | ||
ec=$? | ||
if [[ $ec -eq 0 ]]; then | ||
echo "SUCCESS: $msg" | ||
# Change the git email if the user needs it (ensures the commit is marked as 'Verified') | ||
if [[ -n $GPG_MATCH_GIT_TO_EMAIL ]]; then | ||
msg="Setting user.email in ~/.gitconfig to $GPG_MATCH_GIT_TO_EMAIL" | ||
if git config --global user.email "$GPG_MATCH_GIT_TO_EMAIL"; then | ||
echo "SUCCESS: $msg" | ||
else | ||
echo "ERROR: $msg" | ||
fi | ||
fi | ||
# Ultimately trust the key, bump to lowercase and check the value of the directive | ||
if [[ $(echo "$GPG_AUTO_ULTIMATE_TRUST" | tr '[:upper:]' '[:lower:]') == yes ]]; then | ||
msg="Automagically giving ultimate trust to GPG_KEY_ID: $GPG_KEY_ID" | ||
# Prepend the key id as a trusted hex and update the local database with a silent arbitrary gpg call | ||
echo -e ""trusted-key 0x"$GPG_KEY_ID""\n$(cat $gpg_conf_path)" > "$gpg_conf_path" && | ||
gpg --list-keys &> /dev/null | ||
ec=$? | ||
if [[ $ec -eq 0 ]]; then | ||
echo "SUCCESS: $msg" | ||
else | ||
echo "ERROR: $msg" | ||
fi | ||
fi | ||
else | ||
echo "ERROR: $msg" | ||
fi | ||
fi | ||
# END: Enable GPG key to sign Git commits. | ||
|
||
# Auto activate intelephense if license key is available | ||
if [[ -n $INTELEPHENSE_LICENSEKEY ]]; then | ||
msg="creating $HOME/intelephense/licence.txt" | ||
echo "INTELEPHENSE_LICENSEKEY environment variable found, $msg" | ||
mkdir -p "$HOME/intelephense" && | ||
echo "$INTELEPHENSE_LICENSEKEY" > "$HOME/intelephense/licence.txt" && | ||
ec=$? | ||
if [[ $ec -eq 0 ]]; then | ||
echo "SUCCESS: $msg" | ||
else | ||
echo "ERROR: $msg" | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters