Skip to content

Commit da0221e

Browse files
authored
PR add godpod.io integration with git gpg support (#81)
1 parent dd16fc8 commit da0221e

4 files changed

Lines changed: 145 additions & 0 deletions

File tree

.gitpod.Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM gitpod/workspace-mysql
2+
3+
USER root
4+
5+
# Update APT Database
6+
### base ###
7+
RUN apt-get update -q \
8+
&& apt-get install -y php-dev
9+
10+
# Install XDebug
11+
RUN curl -sSf http://xdebug.org/files/xdebug-3.1.3.tgz | tar xz \
12+
&& cd xdebug-3.1.3 \
13+
&& phpize \
14+
&& ./configure \
15+
&& make install -j$(nproc) \
16+
&& printf 'zend_extension=xdebug\n[XDebug]\nxdebug.remote_enable=1\nxdebug.remote_autostart=1\n' > /etc/php/7.4/mods-available/xdebug.ini \
17+
&& ln -sf /etc/php/7.4/mods-available/xdebug.ini "$(php-config --ini-dir)/20-xdebug.ini"
18+
19+
# Install latest composer v2 release
20+
RUN curl -sSf https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
21+
&& mkdir -p /home/gitpod/.config \
22+
&& chown -R gitpod:gitpod /home/gitpod/.config
23+
24+
USER gitpod
25+
26+
# Install Changelogger
27+
RUN composer global require churchtools/changelogger
28+
29+
# Add Workspace/Project composer bin folder to $PATH
30+
ENV PATH="$PATH:$HOME/.config/composer/vendor/bin:$GITPOD_REPO_ROOT/vendor/bin"

.gitpod.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
image:
2+
file: .gitpod.Dockerfile
3+
4+
ports:
5+
- port: 8000
6+
onOpen: open-browser
7+
- port: 3306
8+
onOpen: ignore
9+
- port: 33060
10+
onOpen: ignore
11+
12+
# List the start up tasks. Learn more https://www.gitpod.io/docs/config-start-tasks/
13+
tasks:
14+
- before: bash .gp/bash/before-tasks.sh
15+
init: |
16+
composer install -o -n
17+
name: Main Terminal
18+
19+
vscode:
20+
extensions:
21+
- felixfbecker.php-debug

.gp/bash/before-tasks.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
#
3+
# SPDX-License-Identifier: MIT
4+
# Copyright © 2021 Apolo Pena
5+
#
6+
# before-tasks.sh
7+
# Description:
8+
# Tasks that should be run every time the workspace is created or started.
9+
#
10+
# Notes:
11+
# Gitpod currently does not persist files in the home directory so we must write them
12+
# in everytime the workspace starts. This is done in the 'before' task in .gitpod.yml
13+
14+
# BEGIN: Enable GPG key to sign Git commits.
15+
# Error handling for improper use of GPG environment variables
16+
err_msg_prefix1="A GPG_KEY was found but it's corresponding GPG_KEY_ID was not."
17+
err_msg_prefix2="A GPG_KEY_ID was found but it's corresponding GPG_KEY was not."
18+
err_msg_suffix="Git commits will not be signed."
19+
[[ -n $GPG_KEY && -z $GPG_KEY_ID ]] &&
20+
echo "ERROR: $err_msg_prefix1 $err_msg_suffix"
21+
[[ -n $GPG_KEY_ID && -z $GPG_KEY ]] &&
22+
echo "ERROR: $err_msg_prefix2 $err_msg_suffix"
23+
# Main GPG key logic
24+
if [[ -n $GPG_KEY && -n $GPG_KEY_ID ]]; then
25+
gpg_conf_path=~/.gnupg/gpg.conf
26+
msg="Enabling Git commit signing for GPG key id: $GPG_KEY_ID"
27+
gpg -q --batch --import <(echo "$GPG_KEY" | base64 -d) &&
28+
echo 'pinentry-mode loopback' >> "$gpg_conf_path" &&
29+
git config --global user.signingkey "$GPG_KEY_ID" &&
30+
git config commit.gpgsign true
31+
ec=$?
32+
if [[ $ec -eq 0 ]]; then
33+
echo "SUCCESS: $msg"
34+
# Change the git email if the user needs it (ensures the commit is marked as 'Verified')
35+
if [[ -n $GPG_MATCH_GIT_TO_EMAIL ]]; then
36+
msg="Setting user.email in ~/.gitconfig to $GPG_MATCH_GIT_TO_EMAIL"
37+
if git config --global user.email "$GPG_MATCH_GIT_TO_EMAIL"; then
38+
echo "SUCCESS: $msg"
39+
else
40+
echo "ERROR: $msg"
41+
fi
42+
fi
43+
# Ultimately trust the key, bump to lowercase and check the value of the directive
44+
if [[ $(echo "$GPG_AUTO_ULTIMATE_TRUST" | tr '[:upper:]' '[:lower:]') == yes ]]; then
45+
msg="Automagically giving ultimate trust to GPG_KEY_ID: $GPG_KEY_ID"
46+
# Prepend the key id as a trusted hex and update the local database with a silent arbitrary gpg call
47+
echo -e ""trusted-key 0x"$GPG_KEY_ID""\n$(cat $gpg_conf_path)" > "$gpg_conf_path" &&
48+
gpg --list-keys &> /dev/null
49+
ec=$?
50+
if [[ $ec -eq 0 ]]; then
51+
echo "SUCCESS: $msg"
52+
else
53+
echo "ERROR: $msg"
54+
fi
55+
fi
56+
else
57+
echo "ERROR: $msg"
58+
fi
59+
fi
60+
# END: Enable GPG key to sign Git commits.
61+
62+
# Auto activate intelephense if license key is available
63+
if [[ -n $INTELEPHENSE_LICENSEKEY ]]; then
64+
msg="creating $HOME/intelephense/licence.txt"
65+
echo "INTELEPHENSE_LICENSEKEY environment variable found, $msg"
66+
mkdir -p "$HOME/intelephense" &&
67+
echo "$INTELEPHENSE_LICENSEKEY" > "$HOME/intelephense/licence.txt" &&
68+
ec=$?
69+
if [[ $ec -eq 0 ]]; then
70+
echo "SUCCESS: $msg"
71+
else
72+
echo "ERROR: $msg"
73+
fi
74+
fi

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[![Coverage Status](https://coveralls.io/repos/github/mlocati/ip-lib/badge.svg?branch=master)](https://coveralls.io/github/mlocati/ip-lib?branch=master)
33
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mlocati/ip-lib/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mlocati/ip-lib/?branch=master)
44
![Packagist Downloads](https://img.shields.io/packagist/dm/mlocati/ip-lib)
5+
[![Open in Gitpod](https://img.shields.io/badge/Open%20in-Gitpod-%232cb64c?logo=gitpod)](https://gitpod.io/#https://github.com/mlocati/ip-lib)
56

67
# IPLib - Handle IPv4, IPv6 and IP ranges
78

@@ -643,6 +644,25 @@ var_export((string) Factory::parseAddressString('127.0.0.0xff:80', ParseStringFl
643644
var_export((string) Factory::parseAddressString('[::%11]:80', ParseStringFlag::MAY_INCLUDE_PORT | ParseStringFlag::MAY_INCLUDE_ZONEID));
644645
```
645646

647+
## Gitpod Environment Variables
648+
649+
The following features can be enabled through environment variables that have been set in your [Gitpod preferences](https://gitpod.io/variables).:
650+
651+
\* _Please note that storing sensitive data in environment variables is not ultimately secure but should be OK for most development situations._
652+
- ### Sign Git commits with a GPG key
653+
- `GPG_KEY_ID` (required)
654+
- The ID of the GPG key you want to use to sign your git commits
655+
- `GPG_KEY` (required)
656+
- Base64 encoded private GPG key that corresponds to your `GPG_KEY_ID`
657+
- `GPG_MATCH_GIT_TO_EMAIL` (optional)
658+
- Sets your git user.email in `~/.gitconfig` to the value provided
659+
- `GPG_AUTO_ULTIMATE_TRUST` (optional)
660+
- If the value is set to `yes` or `YES` then your `GPG_KEY` will be automatically ultimately trusted
661+
- ### Activate an Intelliphense License Key
662+
- `INTELEPHENSE_LICENSEKEY`
663+
- Creates `~/intelephense/licence.txt` and will contain the value provided
664+
- This will activate [Intelliphense](https://intelephense.com/) for you each time the workspace is created or restarted
665+
646666
## Do you really want to say thank you?
647667

648668
You can offer me a [monthly coffee](https://github.com/sponsors/mlocati) or a [one-time coffee](https://paypal.me/mlocati) :wink:

0 commit comments

Comments
 (0)