-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLGCSCS-154: Improvement over docker development environment
- Loading branch information
1 parent
c7b4b6e
commit cc91e4f
Showing
9 changed files
with
149 additions
and
74 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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
EXPOSE_HOST=multisafepay.io | ||
EXPOSE_TOKEN= | ||
APP_SUBDOMAIN=cscart-xxx | ||
MYSQL_TABLE_PREFIX=cscart_ | ||
MYSQL_DATABASE=cscart | ||
MYSQL_USER=cscart | ||
MYSQL_PASSWORD=cscart | ||
CSCART_VERSION=4.x.x.x | ||
CSCART_LICENSE_KEY=YOUR_LICENSE_KEY | ||
CSCART_ADMIN_EMAIL=[email protected] | ||
CSCART_ADMIN_PASSWORD=admin |
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 |
---|---|---|
@@ -1,32 +1,41 @@ | ||
on: | ||
push: | ||
tags: | ||
- '*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
- '*' | ||
name: Upload Release Asset | ||
jobs: | ||
build: | ||
name: Upload Release Asset # Name of the job | ||
runs-on: ubuntu-latest # or windows-latest, macOS-latest | ||
name: Upload Release Asset | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup PHP Action | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.2' | ||
- name: Get the version | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} # Extract the version number from the tag | ||
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | ||
- name: Checkout code | ||
uses: actions/checkout@v2 # Checkout the code | ||
uses: actions/checkout@v2 | ||
- name: Build project | ||
run: ./bin/release.sh ${{ steps.get_version.outputs.VERSION }} # Build the project | ||
run: ./bin/release.sh ${{ steps.get_version.outputs.VERSION }} | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.get_version.outputs.VERSION }} | ||
release_name: Release ${{ steps.get_version.outputs.VERSION }} | ||
draft: true | ||
prerelease: false | ||
- name: Upload Release Asset | ||
run: | | ||
set -x | ||
assets=() | ||
for asset in ./.dist/*.zip; do | ||
assets+=("-a" "$asset") | ||
done | ||
tag_name="${GITHUB_REF##*/}" | ||
hub release create "${assets[@]}" -m "Release $tag_name" "$tag_name" -d | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./.dist/Plugin_CS-Cart_${{ steps.get_version.outputs.VERSION }}.zip | ||
asset_name: Plugin_CS-Cart_${{ steps.get_version.outputs.VERSION }}.zip | ||
asset_content_type: application/zip |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
.DS_Store | ||
.dist | ||
.env | ||
/.idea | ||
/cscart | ||
.dist | ||
.idea | ||
/application | ||
/cscart/* | ||
!/cscart/.gitkeep | ||
/source/* | ||
!/source/.gitkeep |
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 |
---|---|---|
@@ -1,30 +1,80 @@ | ||
include .env | ||
export | ||
|
||
# Escape "@" in the admin email to avoid issues with sed | ||
CSCART_ESCAPED_ADMIN_EMAIL = $(subst @,\@,${CSCART_ADMIN_EMAIL}) | ||
|
||
# Escape "/" and "&" as they have a special meaning in sed and can be part of the password | ||
CSCART_ESCAPED_ADMIN_PASSWORD = $(shell echo "${CSCART_ADMIN_PASSWORD}" | sed 's/[\/&]/\\&/g') | ||
|
||
# Generate the secret key using openssl and base64, and escape special characters for later usage with sed | ||
CSCART_SECRET_KEY := $(shell openssl rand -base64 32 | sed -e 's/[+/=]/\\&/g') | ||
|
||
.PHONY: install | ||
install: install-cscart install-multisafepay | ||
install: validate-email deploy-cscart run-cscart-installer install-multisafepay | ||
|
||
.PHONY: validate-email | ||
validate-email: | ||
@# NOTE: Character "@" suppresses the output of the command or line | ||
@if ! echo "${CSCART_ADMIN_EMAIL}" | grep -E '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$$' > /dev/null; then \ | ||
echo "\nInvalid email address: ${CSCART_ADMIN_EMAIL}.\n\nExiting the script.\n"; \ | ||
exit 1; \ | ||
fi | ||
|
||
.PHONY: check-folder-empty | ||
check-folder-empty: | ||
@echo "Please enter your superuser credentials to allow deletion of necessary files and folders in the './cscart' directory:" | ||
@# Delete all files in cscart directory (except the root .gitkeep and .modman folder and its content). | ||
@# This deletion avoid conflicts with other previous installations, including different CS-Cart versions | ||
@sudo -k find ./cscart -mindepth 1 ! -path './cscart/.gitkeep' ! -path './cscart/.modman/multisafepay' -delete | ||
@# Check if the folder contains other than .gitkeep file and -modman folder (including its content) | ||
@if [ $$(find ./cscart -mindepth 1 -maxdepth 1 ! -path './cscart/.modman' ! -path './cscart/.modman/*' | wc -l) -ne 1 ]; then \ | ||
echo "\nNot all files in the './cscart' folder were removed.\n\nPlease manually delete its contents, except for the root '.gitkeep' file and the '.modman' folder.\n"; \ | ||
exit 1; \ | ||
fi | ||
|
||
.PHONY: install-cscart | ||
install-cscart: download-cscart run-cscart-installer install-multisafepay | ||
.PHONY: deploy-cscart | ||
deploy-cscart: check-folder-empty | ||
@# Decompress the CS-Cart archive to the cscart directory | ||
unzip -o ./source/cscart_v${CSCART_VERSION}.zip -d ./cscart | ||
|
||
.PHONY: run-cscart-installer | ||
run-cscart-installer: | ||
docker-compose exec app curl -o /tmp/wait-for-it.sh https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh | ||
docker-compose exec app chmod +x /tmp/wait-for-it.sh | ||
docker-compose exec app /tmp/wait-for-it.sh db:3306 --timeout=30 | ||
docker-compose exec app sed -i 's/CART-1111-1111-1111-1111/${CSCART_LICENSE_KEY}/' install/config.php | ||
@# In the first segment of the sed command, the "@" in the email doesn’t need escaping since it’s a literal string, not a variable | ||
docker-compose exec app sed -i 's/[email protected]/${CSCART_ESCAPED_ADMIN_EMAIL}/' install/config.php | ||
docker-compose exec app sed -i 's/admin/${CSCART_ESCAPED_ADMIN_PASSWORD}/' install/config.php | ||
docker-compose exec app sed -i 's/YOURVERYSECRETCEY/${CSCART_SECRET_KEY}/' install/config.php | ||
@# Delete in the config file non existing languages: "bg" and "sl" | ||
docker-compose exec app sed -i "s/'bg', 'no', 'sl'/'no'/" install/config.php | ||
docker-compose exec app sed -i 's/localhost/db:3306/' install/config.php | ||
docker-compose exec app sed -i 's/%DB_NAME%/${MYSQL_DATABASE}/' install/config.php | ||
docker-compose exec app sed -i 's/%DB_USER%/${MYSQL_USER}/' install/config.php | ||
docker-compose exec app sed -i 's/%DB_PASS%/${MYSQL_PASSWORD}/' install/config.php | ||
docker-compose exec app sed -i 's/%HTTP_HOST%/https:\/\/${APP_SUBDOMAIN}.${EXPOSE_HOST}/' install/config.php | ||
docker-compose exec app /bin/sh -c 'cd install && php index.php' | ||
docker-compose exec app mysql -hdb -u${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE} -e "UPDATE cscart_settings_objects SET value = 'Y' WHERE name = 'secure_admin' OR name = 'secure_storefront'" | ||
|
||
.PHONY: download-cscart | ||
download-cscart: | ||
docker-compose exec app curl -L "https://www.cs-cart.com/index.php?dispatch=pages.get_trial&page_id=297&edition=ultimate" -o cscart.zip -s | ||
docker-compose exec app unzip -o -q cscart.zip | ||
docker-compose exec app mysql -h db -u ${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE} -e "UPDATE ${MYSQL_TABLE_PREFIX}settings_objects SET value = 'Y' WHERE name = 'secure_admin' OR name = 'secure_storefront'" | ||
docker-compose exec app rm /tmp/wait-for-it.sh | ||
|
||
.PHONY: install-multisafepay | ||
install-multisafepay: | ||
docker-compose exec app php msp_installer.php | ||
install-multisafepay: msp-installer modman-deploy | ||
@# - ignore the error if the command fails | ||
@# || true ensures that the command returns a successful exit code due | ||
@# to the errors that chown throws when pass through .git folder | ||
@-docker-compose exec app chown -R www-data:www-data /var/www/ > /dev/null 2>&1 || true | ||
|
||
.PHONY: msp-installer | ||
msp-installer: | ||
docker cp ./src/msp_installer.php $$(docker-compose ps -q app):/var/www/html/msp_installer.php | ||
docker-compose exec app chmod +x /var/www/html/msp_installer.php | ||
@docker-compose exec app php /var/www/html/msp_installer.php || (echo "msp_installer.php failed" && exit 1) | ||
|
||
.PHONY: modman-deploy | ||
modman-deploy: | ||
docker-compose exec app modman deploy-all | ||
|
||
.PHONY: modman | ||
modman: | ||
|
@@ -33,4 +83,3 @@ modman: | |
.PHONY: modman-copy | ||
modman-copy: | ||
docker-compose exec app modman deploy multisafepay --copy --force --quiet | ||
|
Empty file.
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 |
---|---|---|
@@ -1,36 +1,44 @@ | ||
version: '3.3' | ||
|
||
services: | ||
app: | ||
depends_on: | ||
- db | ||
build: . | ||
build: | ||
context: . | ||
sysctls: | ||
- net.ipv4.ip_unprivileged_port_start=0 | ||
volumes: | ||
- ./:/var/www/html/.modman/multisafepay | ||
- ./msp_installer.php:/var/www/html/msp_installer.php | ||
- ./cscart:/var/www/html/ | ||
environment: | ||
PHP_IDE_CONFIG: "serverName=app" | ||
db: | ||
image: 'mysql:5.7' | ||
image: "mysql:5.7" | ||
platform: linux/x86_64 | ||
command: --default-authentication-plugin=mysql_native_password | ||
# restart: always | ||
environment: | ||
MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD} | ||
MYSQL_DATABASE: ${MYSQL_DATABASE} | ||
MYSQL_USER: ${MYSQL_USER} | ||
MYSQL_PASSWORD: ${MYSQL_PASSWORD} | ||
mail: | ||
image: 'mailhog/mailhog' | ||
image: "mailhog/mailhog" | ||
platform: linux/x86_64 | ||
ports: | ||
- 8025:8025 | ||
- "8025:8025" | ||
adminer: | ||
image: adminer:latest | ||
platform: linux/arm64/v8 | ||
ports: | ||
- "8080:8080" | ||
depends_on: | ||
- db | ||
links: | ||
- db | ||
expose: | ||
depends_on: | ||
- app | ||
build: https://github.com/beyondcode/expose.git | ||
entrypoint: ["/bin/sh", "-c" , "/src/expose token ${EXPOSE_TOKEN} && sed -i -E \"s/'dns'\\s?=>\\s?'.*'/'dns' => true/g\" /root/.expose/config.php && /src/expose share app --server-host=${EXPOSE_HOST} --subdomain=${APP_SUBDOMAIN}"] | ||
ports: | ||
- 4040:4040 | ||
- "4040:4040" |
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
Empty file.