-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
188 additions
and
75 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
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
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
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 |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
|
||
## Creating new project | ||
|
||
1. Check your GitHub SSH connection `ssh -T [email protected]` | ||
1. Check your GitHub SSH connection `ssh -T [email protected]` or use [Personal Access Token](#cicd-deployments) in `.env.secret` `COMPOSER_AUTH` | ||
|
||
2. Create a new project directory and clone this repository into the project folder. | ||
|
||
|
@@ -315,24 +315,39 @@ Use GitHub Actions, GitLab CI/CD or other pipelines. | |
3. Add secrets variables to repo options: | ||
|
||
- `SSH_KEY` - Private key from deploy pair that used for servers access | ||
- `SSH_CONFIG_DEV` - SSH config for develop server with address, port, user, etc. See the example | ||
- `SSH_CONFIG_STAGE` - Same for staging | ||
- `SSH_CONFIG_PROD` - SSH config for production server | ||
- `SSH_CONFIG` - SSH config for servers with address, port, user, etc. See the example | ||
- `COMPOSER_AUTH` - [Composer authentication](https://getcomposer.org/doc/articles/authentication-for-private-packages.md) JSON object with Personal Access Token, see [Managing your personal access tokens on GitHub](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) | ||
and [Personal access tokens on GitLab](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html). For local usage in `.env.secret` file use a serialized **unescaped** JSON object without spaces, for GitHub secrets use **escaped** JSON object without spaces. | ||
|
||
SSH config example: | ||
```conf | ||
# SSH_CONFIG | ||
Host * | ||
IdentitiesOnly yes | ||
StrictHostKeyChecking no | ||
Host ssh_alias | ||
HostName starter-kit.io | ||
# Develop server ssh alias | ||
Host develop.starter-kit.io | ||
HostName 00.00.00.00 | ||
User serverusername | ||
Port 22 | ||
Host github.com | ||
HostName github.com | ||
User git | ||
# Prod server ssh alias | ||
Host starter-kit.io | ||
HostName 00.00.00.00 | ||
User serverusername | ||
Port 22 | ||
``` | ||
|
||
COMPOSER_AUTH example for GitHub secrets: | ||
```bash | ||
{\"github-oauth\":{\"github.com\":\"ACCESS_TOKEN_GITHUB\"}} | ||
``` | ||
|
||
COMPOSER_AUTH example for local usage: | ||
```bash | ||
{"github-oauth":{"github.com":"ACCESS_TOKEN_GITHUB"}} | ||
``` | ||
|
||
4. Check CI/CD jobs config file, use `./.github` for GitHub Actions | ||
|
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
17 changes: 17 additions & 0 deletions
17
dockerfiles/composer/docker-entrypoint.d/30-composer-config.sh
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,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail | ||
|
||
# Current file | ||
ME=$(basename "$0") | ||
|
||
entrypoint_log() { | ||
if [ -z "${PHP_ENTRYPOINT_QUIET_LOGS:-}" ]; then | ||
echo "$@" | ||
fi | ||
} | ||
|
||
# Using COMPOSER_AUTH JSON object for Composer authentication | ||
if [ ! -z "${COMPOSER_AUTH:-}" ]; then | ||
entrypoint_log "$ME: Used COMPOSER_AUTH JSON object for Composer authentication" | ||
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
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,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail | ||
|
||
# Current file | ||
ME=$(basename "$0") | ||
|
||
entrypoint_log() { | ||
if [ -z "${PHP_ENTRYPOINT_QUIET_LOGS:-}" ]; then | ||
echo "$@" | ||
fi | ||
} | ||
|
||
# Recreate www-data user | ||
# Fix www-data UID from 82 to ${CURRENT_UID} (Permission denied error) | ||
# Deleting default user (with group) | ||
deluser www-data | ||
# 82 is the standard uid/gid for "www-data" in Alpine | ||
# https://git.alpinelinux.org/aports/tree/main/apache2/apache2.pre-install?h=3.14-stable | ||
# https://git.alpinelinux.org/aports/tree/main/lighttpd/lighttpd.pre-install?h=3.14-stable | ||
# https://git.alpinelinux.org/aports/tree/main/nginx/nginx.pre-install?h=3.14-stable | ||
|
||
addgroup -g "${CURRENT_GID}" "${DEFAULT_USER}" | ||
adduser -u "${CURRENT_UID}" -D -G "${DEFAULT_USER}" "${DEFAULT_USER}" | ||
chown "${DEFAULT_USER}":"${DEFAULT_USER}" /var/log/wordpress | ||
|
||
echo "${DEFAULT_USER} user UID=${CURRENT_UID} updated" |
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,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail | ||
|
||
# Current file | ||
ME=$(basename "$0") | ||
|
||
entrypoint_log() { | ||
if [ -z "${PHP_ENTRYPOINT_QUIET_LOGS:-}" ]; then | ||
echo "$@" | ||
fi | ||
} | ||
|
||
replace_env_vars() { | ||
local template_dir="$1" | ||
local output_dir="$2" | ||
local suffix="${PHP_ENVSUBST_TEMPLATE_SUFFIX:-.template}" | ||
local filter="${PHP_ENVSUBST_FILTER:-}" | ||
|
||
local template defined_envs relative_path output_path subdir | ||
defined_envs=$(printf '${%s} ' $(awk "END { for (name in ENVIRON) { print ( name ~ /${filter}/ ) ? name : \"\" } }" < /dev/null )) | ||
[ -d "$template_dir" ] || return 0 | ||
if [ ! -w "$output_dir" ]; then | ||
entrypoint_log "$ME: ERROR: $template_dir exists, but $output_dir is not writable" | ||
return 0 | ||
fi | ||
find "$template_dir" -follow -type f -name "*$suffix" -print | while read -r template; do | ||
relative_path="${template#"$template_dir/"}" | ||
output_path="$output_dir/${relative_path%"$suffix"}" | ||
subdir=$(dirname "$relative_path") | ||
# create a subdirectory where the template file exists | ||
mkdir -p "$output_dir/$subdir" | ||
entrypoint_log "$ME: Running envsubst on $template to $output_path" | ||
envsubst "$defined_envs" < "$template" > "$output_path" | ||
done | ||
} | ||
|
||
# Replace env variables with values in sSMTP config using gettext app | ||
replace_env_vars "/etc/ssmtp/templates" "/etc/ssmtp" |
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
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
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
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 |
---|---|---|
|
@@ -64,3 +64,11 @@ SSMTP_REVALIASES=root:[email protected]:mailhub.your.domain[:port] | |
APP_BA_USER=control_area | ||
APP_BA_PASSWORD=generate_this_pass | ||
|
||
# Set GitHub or GitLab auth token to securely use packages. | ||
# Use a serialized JSON object without spaces | ||
# For GitHub secrets use escaped JSON object without spaces | ||
# https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens | ||
# https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html | ||
# For GitHub Secrets | ||
#COMPOSER_AUTH={\"github-oauth\":{\"github.com\":\"ACCESS_TOKEN_GITHUB\"}} | ||
#COMPOSER_AUTH={"github-oauth":{"github.com":"ACCESS_TOKEN_GITHUB"}} |