├── _config.yml
├── wordpress
├── cloud-run-entrypoint.sh
└── wp-config.php
├── apache
├── ports.conf
└── 000-default.conf
├── README.md
├── Dockerfile
└── LICENSE
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-slate
--------------------------------------------------------------------------------
/wordpress/cloud-run-entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Start the sql proxy
4 | cloud_sql_proxy -instances=$CLOUDSQL_INSTANCE=tcp:3306 &
5 |
6 | # Execute the rest of your ENTRYPOINT and CMD as expected.
7 | exec "$@"
--------------------------------------------------------------------------------
/apache/ports.conf:
--------------------------------------------------------------------------------
1 | # If you just change the port or add more ports here, you will likely also
2 | # have to change the VirtualHost statement in
3 | # /etc/apache2/sites-enabled/000-default.conf
4 |
5 | #Listen 80
6 | Listen 8080
7 |
8 |
9 | Listen 443
10 |
11 |
12 |
13 | Listen 443
14 |
15 |
16 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cloud-run-wordpress
2 | Medium article: [Deploy a Wordpress site on Google Cloud Run](https://medium.com/@salvopappalardo/how-to-install-a-wordpress-site-on-google-cloud-run-828bdc0d0e96)
3 |
4 | # Deploy steps
5 | ## Build image
6 | ```sh
7 | gcloud builds submit --tag gcr.io/[PROJECT-ID]/wp:v1
8 | ```
9 | ## Deploy image
10 | ```
11 | gcloud beta run deploy wp --image gcr.io/[PROJECT-ID]/wp:v1 \
12 | --add-cloudsql-instances \
13 | --update-env-vars DB_HOST='127.0.0.1',DB_NAME=,DB_USER=,DB_PASSWORD=,CLOUDSQL_INSTANCE='::'
14 | ```
15 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # https://github.com/docker-library/wordpress/blob/9ee913eea382b5d79f852a2301d4390904d2e4d2/php7.3/apache/Dockerfile
2 | FROM wordpress:5.2.1-php7.3-apache
3 |
4 | EXPOSE 8080
5 | # Use the PORT environment variable in Apache configuration files.
6 | RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
7 | # wordpress conf
8 | COPY wordpress/wp-config.php /var/www/html/wp-config.php
9 |
10 | # download and install cloud_sql_proxy
11 | RUN apt-get update && apt-get -y install net-tools wget && \
12 | wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O /usr/local/bin/cloud_sql_proxy && \
13 | chmod +x /usr/local/bin/cloud_sql_proxy
14 |
15 | # custom entrypoint
16 | COPY wordpress/cloud-run-entrypoint.sh /usr/local/bin/
17 |
18 | ENTRYPOINT ["cloud-run-entrypoint.sh","docker-entrypoint.sh"]
19 | CMD ["apache2-foreground"]
20 |
--------------------------------------------------------------------------------
/apache/000-default.conf:
--------------------------------------------------------------------------------
1 |
2 | # The ServerName directive sets the request scheme, hostname and port that
3 | # the server uses to identify itself. This is used when creating
4 | # redirection URLs. In the context of virtual hosts, the ServerName
5 | # specifies what hostname must appear in the request's Host: header to
6 | # match this virtual host. For the default virtual host (this file) this
7 | # value is not decisive as it is used as a last resort host regardless.
8 | # However, you must set it for any further virtual host explicitly.
9 | #ServerName www.example.com
10 |
11 | ServerAdmin webmaster@localhost
12 | DocumentRoot /var/www/html
13 |
14 | # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
15 | # error, crit, alert, emerg.
16 | # It is also possible to configure the loglevel for particular
17 | # modules, e.g.
18 | #LogLevel info ssl:warn
19 |
20 | ErrorLog ${APACHE_LOG_DIR}/error.log
21 | CustomLog ${APACHE_LOG_DIR}/access.log combined
22 |
23 | # For most configuration files from conf-available/, which are
24 | # enabled or disabled at a global level, it is possible to
25 | # include a line for only one particular virtual host. For example the
26 | # following line enables the CGI configuration for this host only
27 | # after it has been globally disabled with "a2disconf".
28 | #Include conf-available/serve-cgi-bin.conf
29 |
30 |
31 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
--------------------------------------------------------------------------------
/wordpress/wp-config.php:
--------------------------------------------------------------------------------
1 |