使用Docker和Fabric启动新Web项目的框架

网友投稿 950 2022-10-27

使用Docker和Fabric启动新Web项目的框架

使用Docker和Fabric启动新Web项目的框架

JoliCode's Docker starter kit

Before using the stack (remove this chapter once done)

Project configuration

Before executing any command, you need to configure few parameters in the fabfile.py file:

env.project_name: This will be used to prefix all docker objects (network, images, containers)env.project_directory: This is the host directory containing your PHP applicationenv.project_hostnames: This will be all your domain names, separated with comma

Note: Some Fabric tasks have been added for DX purposes. Checkout and adapt the tasks install, migrate and cache_clear to your project

SSL certificate

To save your time with certificate generation, this project already embed a basic self-signed certificate. So HTTPS will work out of the box in your browser as soon as you accept this self-signed certificate.

However, if you prefer to have valid certificate in local (some tools do not necessarily let you work with invalid certificates), you will have to:

generate a certificate valid for your domain namesign this certificate with a locally trusted CA

In this case, it's recommended to use more powerful tool like mkcert. As mkcert uses a CA root, you will need to generate a certificate on each computer using this stack and so add /infrastructure/services/router/certs/ to the .gitignore file.

Alternatively, you can configure infrastructure/docker/services/router/openssl-f then use infrastructure/docker/services/router/generate-ssl.sh to create your own certificate. Then you will have to add it to your computer CA store.

Running the application locally

Requirements

A Docker environment is provided and requires you to have these tools available:

Dockerpipenv (see these instructions for how to install)

Install and run pipenv to install the required tools:

pipenv install

You can configure your current shell to be able to use fabric commands directly (without having to prefix everything by pipenv run)

pipenv shell

Domain configuration (first time only)

Before running the application for the first time, ensure your domain names point the IP of your Docker daemon by editing your /etc/hosts file.

This IP is probably 127.0.0.1 unless you run Docker in a special VM (docker-machine, dinghy, etc).

Note: The router binds port 80 and 443, that's why it will work with 127.0.0.1

echo '127.0.0.1 ' | sudo tee -a /etc/hosts

Using dinghy? Run dinghy ip to get the IP of the VM.

Starting the stack

Launch the stack by running this command:

fab start

Note: the first start of the stack should take a few minutes.

The site is now accessible at the hostnames your have configured over HTTPS (you may need to accept self-signed SSL certificate).

Builder

Having some composer, yarn or another modifications to make on the project? Start the builder which will give you access to a container with all these tools available:

fab builder

Note: You can add as many fabric command as you want. But the command should be ran by the builder, don't forget to add @with_builder annotation to the function.

Other tasks

Checkout fab -l to have the list of available fabric tasks.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:记第一次参加校招..
下一篇:YTU.2326: 大数的乘法【数组】
相关文章

 发表评论

暂时没有评论,来抢沙发吧~