You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rest of Dockerfile is same as Dockerfile for CGI above.
185
+
186
+
## Deploy Fano FastCGI Application with Docker
187
+
188
+
### Create Dockerfile
189
+
For FastCGI that runs as separate server via reverse-proxy module, i.e, using `--project-fcgi`, you can run Fano application and Apache as separate docker container and run it with `docker-compose`.
190
+
191
+
```
192
+
$ fanocli --project-fcgi=testfano
193
+
```
194
+
195
+
For that we need to create two Dockerfiles for Fano application and Apache.
196
+
197
+
### Dockerfile for Fano application
198
+
199
+
Dockerfile for Fano application is just pull Ubuntu image and copy binary executable, configuration file, HTML templates etc.
200
+
201
+
Last, we tells Docker to execute application and listen on `0.0.0.0:7704`. Parameter `--host=0.0.0.0` is required, otherwise our application will only listen on `127.0.0.1`. Because Apache will act as reverse-proxy server on different container, it will not be able to connect to Fano application without `--host=0.0.0.0`.
Dockerfile for Apache mostly similar to above Dockerfile for CGI but with goal to setup Apache as FastCGI reverse proxy server that connect to our application. This is done by tells Apache to load `mod_proxy` and `mod_proxy_fcgi`.
We copy `vhost.example` into container virtual host configuraton. We will create it latter.
246
+
247
+
We name this Dockerfile as `httpd_dockerfile`.
248
+
249
+
### Create virtual host configuration
250
+
We create new file `vhost.example` with content aim to setup FastCGI reverse proxy. `fcgi://fano:7704` line tells Apache to forward FastCGI data to our application container identified as `fano` (This is service we defined in `docker-compose.yaml` below).
To simplify running both application, we use docker-compose with configuration like so
263
+
264
+
```
265
+
version: "2"
266
+
services:
267
+
fano:
268
+
build:
269
+
context: .
270
+
dockerfile: fano_dockerfile
271
+
ports:
272
+
- "7704:7704"
273
+
apache:
274
+
build:
275
+
context: .
276
+
dockerfile: httpd_dockerfile
277
+
depends_on:
278
+
- fano
279
+
```
280
+
281
+
Here we tells docker-compose to build two services from two dockerfiles we previously created. We also forward traffic on port `7704` so that Apache container can connect it.
282
+
283
+
Do not forget to save it as `docker-compose.yaml`.
284
+
285
+
### Run FastCGI application with docker-compose
286
+
287
+
To run application and Apache, run build.sh script first and then,
288
+
289
+
```
290
+
$ docker-compose up
291
+
```
292
+
293
+
To access application, we need to get IP address of Apache container image.
294
+
Run
295
+
296
+
```
297
+
$ docker network ls
298
+
```
299
+
300
+
It will list all Docker available networks. If our application is in `testfano` directory,
301
+
it will be listed as `testfano_default` by default. To get IP address
302
+
303
+
```
304
+
$ docker network inspect testfano_default
305
+
```
306
+
307
+
Find IP address for Apache, for example if it prints `172.20.0.3/16`
308
+
Then open browser and visit `http://172.20.0.3` to access our application.
309
+
310
+
## Deploy Fano SCGI Application with Docker
311
+
312
+
This will mostly similar to FastCGI reverse proxy setup above, except that `httpd_dockerfile` will load `mod_proxy_scgi` and `vhost.example` contains `scgi://fano:7704` line
313
+
314
+
## Deploy Fano uwsgi Application with Docker
315
+
316
+
This will mostly similar to FastCGI reverse proxy setup above, except that `httpd_dockerfile` will load `mod_proxy_uwsgi` and `vhost.example` contains `uwsgi://fano:7704` line
317
+
318
+
## Deploy Fano CLI-generated Project with Docker
319
+
320
+
[Fano CLI](/scaffolding-with-fano-cli/) since `v1.13.0` generates `docker-compose.yaml` file during creation of [CGI](/scaffolding-with-fano-cli/creating-project/#scaffolding-cgi-project), [FastCGI](/scaffolding-with-fano-cli/creating-project/#scaffolding-fcgid-project), [SCGI](/scaffolding-with-fano-cli/creating-project/#scaffolding-scgi-project) and [uwsgi](/scaffolding-with-fano-cli/creating-project/#scaffolding-uwsgi-project) project.
321
+
322
+
Which means you can skip steps above and just compile application and then run with `docker-compose up`.
323
+
324
+
## Explore more
325
+
326
+
-[Scaffolding with Fano CLI](/scaffolding-with-fano-cli/)
0 commit comments