Skip to content

Commit 240f5b7

Browse files
committed
Fixed #93
1 parent b808871 commit 240f5b7

File tree

6 files changed

+83
-82
lines changed

6 files changed

+83
-82
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ dist
1212
node_modules
1313
private
1414
public_html
15+
build

.magento.docker.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.magento.setup.params

Lines changed: 0 additions & 21 deletions
This file was deleted.

Makefile

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,41 @@
11
VENDOR=JetRails
22
MODULE=Cloudflare
3-
MAGENTO_VERSION=2.4.4
4-
MAGENTO_EDITION=community
5-
NAMESPACE=$(VENDOR)"_"$(MODULE)
6-
NAMESPACE_PATH=$(VENDOR)"/"$(MODULE)
3+
NAMESPACE=$(VENDOR)_$(MODULE)
4+
NAMESPACE_PATH=$(VENDOR)/$(MODULE)
75
VERSION=$(shell git describe --tags `git rev-list --tags --max-count=1`)
86
MODULE_FILES=Block Console Controller Helper Model etc view registration.php
97
MODULE_FILES_EXTRA=composer.json LICENSE.md
108

11-
.PHONY: deps build bump deploy watch package clean nuke dev-create dev-up dev-down dev-nuke
9+
.PHONY: deps build bump deploy package clean help
1210

1311
deps: ## Download dependencies
1412
yarn install
1513

1614
build: ## Build styles and scripts
1715
yarn build
16+
rm -rf ./build/$(NAMESPACE_PATH)
17+
mkdir -p ./build/$(NAMESPACE_PATH)
18+
rsync -uavq $(MODULE_FILES) ./build/$(NAMESPACE_PATH)
1819

1920
bump: ## Bump version in source files based on latest git tag
2021
VERSION=$(VERSION); find Block Console Controller Helper Model etc view -type f -iname "*.php" -exec sed -E -i '' "s/([\t ]+\*[\t ]+@version[\t ]+)(.*)/\1$$VERSION/g" {} +
2122
VERSION=$(VERSION); sed -E -i '' "s/(Version-)(.+)(-orange)/\1$$VERSION\3/g" ./README.md
2223
VERSION=$(VERSION); sed -E -i '' "s/(\"version\": \")(.+)(\")/\1$$VERSION\3/g" ./composer.json
2324
VERSION=$(VERSION); sed -E -i '' "s/(\"version\": \")(.+)(\")/\1$$VERSION\3/g" ./package.json
2425

25-
deploy: ## Deploy code to public_html directory
26-
NAMESPACE_PATH=$(NAMESPACE_PATH); mkdir -p "./public_html/app/code/$$NAMESPACE_PATH"
27-
NAMESPACE_PATH=$(NAMESPACE_PATH); rsync -uavq $(MODULE_FILES) "./public_html/app/code/$$NAMESPACE_PATH"
28-
29-
watch: deploy ## Intermittently sync code to public_html directory
30-
fswatch -o $(MODULE_FILES) | xargs -n1 -I{} make deploy
26+
deploy: build ## Deploy code to docker container
27+
docker compose exec magento rm -rf /bitnami/magento/app/code/$(NAMESPACE_PATH)
28+
docker compose exec magento mkdir -p /bitnami/magento/app/code/$(NAMESPACE_PATH)
29+
docker compose cp ./build/$(NAMESPACE_PATH) magento:/bitnami/magento/app/code/$(VENDOR)
30+
docker compose exec magento chown -R daemon:root /bitnami/magento/app/code
3131

3232
package: bump build ## Package into archive file
3333
rm -rf ./dist
3434
mkdir -p ./dist
35-
VERSION=$(VERSION); NAMESPACE=$(NAMESPACE); zip -r dist/$$NAMESPACE-$$VERSION.zip $(MODULE_FILES) $(MODULE_FILES_EXTRA)
35+
zip -r dist/$(NAMESPACE)-$(VERSION).zip $(MODULE_FILES) $(MODULE_FILES_EXTRA)
3636

3737
clean: ## Remove generated files and folders
38-
rm -rf ./dist ./.parcel-cache
39-
40-
nuke: clean ## Remove generated & deployment data
41-
rm -rf ./node_modules ./public_html
42-
43-
install-from-magento: ## Install module from official Magento repo (for testing)
44-
docker-compose -f ./public_html/docker-compose.yml run --rm build composer require --no-ansi jetrails/magento2-cloudflare:1.4.0
45-
46-
shell: ## Spawn a shell
47-
docker-compose -f ./public_html/docker-compose.yml run --rm deploy bash
48-
49-
dev-create: ## Create development environment
50-
composer global config repositories.magento composer https://repo.magento.com/
51-
composer create-project --prefer-dist --repository-url=https://repo.magento.com/ magento/project-$(MAGENTO_EDITION)-edition=$(MAGENTO_VERSION) ./public_html
52-
cp .magento.docker.yml .magento.setup.params ./public_html
53-
cd public_html && ln -s ../docker-compose.override.yml ./docker-compose.override.yml
54-
cd public_html && composer require magento/ece-tools -w
55-
cd public_html && ./vendor/bin/ece-docker build:compose --no-varnish --mode developer
56-
cd public_html && docker-compose up -d
57-
cd public_html && docker-compose run --rm deploy composer self-update --2
58-
cd public_html && docker-compose run --rm deploy magento-command setup:install `cat .magento.setup.params | tr '\n' ' '` ;
59-
cd public_html && docker-compose run --rm deploy magento-command module:disable Magento_TwoFactorAuth
60-
cd public_html && docker-compose run --rm deploy magento-command cache:flush
61-
cd public_html && docker-compose run --rm deploy magento-command deploy:mode:set developer -s
62-
# cd public_html && docker-compose run --rm deploy magento-command setup:static-content:deploy --jobs 4
63-
cd public_html && docker-compose run --rm deploy magento-command setup:di:compile
64-
65-
dev-up: ## Spin development environment up
66-
docker-compose -f ./public_html/docker-compose.yml up -d
67-
68-
dev-down: ## Spin development environment down
69-
docker-compose -f ./public_html/docker-compose.yml down
70-
71-
dev-nuke: dev-down nuke ## Spin development environment down
72-
docker volume rm public_html_magento-development-magento-db
38+
rm -rf ./dist ./build ./.parcel-cache
7339

7440
help: ## Display available commands
7541
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,42 @@
1111
</p>
1212

1313
## Documentation
14+
1415
The user guide can be found [here](https://learn.jetrails.com/article/magento-2-cloudflare-extension). The user guide goes through the installation process as well as explains all the features that comes with this extension. For further support, please email [development@jetrails.com](mailto://development@jetrails.com).
1516

1617
## Build System
18+
1719
A simple [Makefile](Makefile) is used as a build system. Run `make help` to see available commands.
1820

19-
## Development
20-
Run `make dev-create` to create a docker development environment using the [magento-cloud-docker](https://github.com/magento/magento-cloud-docker) project. Run `make dev-down` spin the environment down, `make dev-up` to spin it back up, and `make dev-nuke` to completely remove everything that is ephemeral.
21+
## Development Environment
22+
23+
We use a super simple development environment that is ephemeral. You can spin it up by doing the following:
24+
25+
```shell
26+
docker compose up -d
27+
docker compose logs -f
28+
docker compose down # destroy environment
29+
```
30+
31+
You can deploy the module into the development environment by running the following:
32+
33+
```shell
34+
make clean
35+
make build
36+
make deploy
37+
```
38+
39+
You can then access the magento container by running the following:
40+
41+
```shell
42+
docker compose exec magento bash
43+
```
44+
45+
Once in the container you can run the standard commands to install the module:
46+
47+
```shell
48+
magento setup:upgrade
49+
magento setup:di:compile
50+
```
51+
52+
The Magento site is hosted on http://localhost and the backend can be reached at http://localhost/admin. Default user name is `jetrails` and default password is `magento2`.

docker-compose.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: "2"
2+
3+
services:
4+
elasticsearch:
5+
image: docker.io/bitnami/elasticsearch:7
6+
mariadb:
7+
image: docker.io/bitnami/mariadb:10.3
8+
environment:
9+
- ALLOW_EMPTY_PASSWORD=yes
10+
- MARIADB_USER=magento2
11+
- MARIADB_DATABASE=magento2
12+
magento:
13+
image: docker.io/bitnami/magento:2
14+
environment:
15+
- MAGENTO_HOST=localhost
16+
- MAGENTO_DATABASE_HOST=mariadb
17+
- MAGENTO_DATABASE_PORT_NUMBER=3306
18+
- MAGENTO_DATABASE_USER=magento2
19+
- MAGENTO_DATABASE_NAME=magento2
20+
- MAGENTO_USERNAME=jetrails
21+
- MAGENTO_PASSWORD=magento2
22+
- MAGENTO_MODE=developer
23+
- MAGENTO_ENABLE_HTTPS=yes
24+
- MAGENTO_ENABLE_ADMIN_HTTPS=yes
25+
- MAGENTO_ADMIN_URL_PREFIX=admin
26+
- ELASTICSEARCH_HOST=elasticsearch
27+
- ELASTICSEARCH_PORT_NUMBER=9200
28+
- ALLOW_EMPTY_PASSWORD=yes
29+
- MAGENTO_ENABLE_HTTP_CACHE=no
30+
ports:
31+
- '80:8080'
32+
- '443:8443'
33+
depends_on:
34+
- mariadb
35+
- elasticsearch

0 commit comments

Comments
 (0)