Skip to content

Commit

Permalink
Configure PHP Docker to work with deprecated MySQL code (thewca#7468)
Browse files Browse the repository at this point in the history
* Activate correct MySQL bindings in PHP container

* Remove all mentions of Vagrant
  • Loading branch information
gregorbg authored Dec 17, 2022
1 parent 6a87f71 commit 7eeda13
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 88 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ WcaOnRails/public/documents/*
# byebug stuff
.byebug_history

# Vagrant stuff
.vagrant/

# phpBB mess
webroot/forum/cache/*
!webroot/forum/cache/.htaccess
Expand Down
1 change: 0 additions & 1 deletion .overcommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ PreCommit:
- 'WcaOnRails/config/locales/*.yml'
- 'chef/**/*'
- '.gitmodules'
- 'Vagrantfile'
- '**/*.pdf'
- '**/*.jpg'
- '**/*.png'
Expand Down
20 changes: 0 additions & 20 deletions Vagrantfile

This file was deleted.

13 changes: 0 additions & 13 deletions WcaOnRails/app/uploaders/avatar_uploader_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,3 @@ def full_original_filename
end
end
end

if File.exist? "/vagrant"
# Workaround for Vagrant bug with sendfile.
# carrierwave uses FileUtils.cp to copy around files that it
# mutates with mogrify, which exposes this bug.
# See https://github.com/mitchellh/vagrant/issues/351.
module FileUtils
def cp(src, dest, **options)
`cp #{src.shellescape} #{dest.shellescape}`
end
module_function :cp
end
end
1 change: 0 additions & 1 deletion chef/client.rb

This file was deleted.

2 changes: 1 addition & 1 deletion chef/roles/wca.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"authorization": {
"sudo": {
"groups": ["admin", "sudo", "sysadmin"],
"users": ["vagrant", "cubing"],
"users": ["cubing"],
"passwordless": "true"
}
},
Expand Down
5 changes: 0 additions & 5 deletions chef/site-cookbooks/wca/chefignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ Strainerfile
.colander
.strainer

# Vagrant #
###########
.vagrant
Vagrantfile

# Travis #
##########
.travis.yml
13 changes: 5 additions & 8 deletions chef/site-cookbooks/wca/libraries/wca_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
module WcaHelper
# gregorbg: This method exists as a relic from a time when we needed to distinguish between "real" servers and Vagrant.
# Now that we're planning to get rid of Chef entirely, I didn't bother to properly refactor this.
def self.get_username_and_repo_root(recipe)
vagrant_user = recipe.node['etc']['passwd']['vagrant']
if vagrant_user
username = "vagrant"
repo_root = "/vagrant"
else
username = "cubing"
repo_root = "/home/#{username}/worldcubeassociation.org"
end
username = "cubing"
repo_root = "/home/#{username}/worldcubeassociation.org"

return [ username, repo_root ]
end

Expand Down
4 changes: 1 addition & 3 deletions chef/site-cookbooks/wca/templates/rc.local.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/sh -e

# sleep as a hack to wait for vagrant to mount the /vagrant directory, which is
# needed for our screen session
sudo su <%= @username %> -c 'sleep 10; ~/startall'&
sudo su <%= @username %> -c '~/startall'&

exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,8 @@ upstream app {
server {
server_name <%= @server_name %> localhost;

<% if @rails_env == "development" %>
# Using sendfile isn't reliable in VirtualBox. See:
# http://wiki.nginx.org/Pitfalls#VirtualBox
sendfile off;
# In development, we're running behind Vagrant's proxy (host port 2331).
# If we run nginx on a different port (say 80), then when nginx sends redirects,
# they will be to port 80, which doesn't work from outside the vm.
listen 2331;
<% else %>
# SSL is handled by the AWS Load Balancer and is only reachable through it
listen 80;
<% end %>

# Deny access to dotfiles and dotfolders.
location ~ /\. {
Expand Down
42 changes: 21 additions & 21 deletions docker-compose.php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ services:
image: nginx
ports:
- "8080:8080"
volumes:
- ./webroot:/webroot #PHP stuff
- ./WcaOnRails/app/views/regulations:/regulations #static regulations files
- ./WcaOnRails/public:/public #other static files
- ./docker/nginx-dev.conf:/etc/nginx/conf.d/default.conf
- ./docker/fcgi.conf:/etc/nginx/fcgi.conf
networks:
- wca-main
depends_on:
- php
- wca_on_rails
volumes:
- ./webroot:/webroot #PHP stuff
- ./WcaOnRails/app/views/regulations:/regulations #static regulations files
- ./WcaOnRails/public:/public #other static files
- ./docker/nginx-dev.conf:/etc/nginx/conf.d/default.conf
- ./docker/fcgi.conf:/etc/nginx/fcgi.conf
networks:
- wca-main
depends_on:
- php
- wca_on_rails

php:
build:
dockerfile: './docker/php-dockerfile'
php:
build:
dockerfile: './docker/php-dockerfile'
volumes:
- ./webroot:/webroot
- ./secrets/uploads:/secrets/uploads # so we can pretend to upload stuff
networks:
- wca-main
environment:
- MYSQL_HOST=wca_db
- MYSQL_USER=root
- MYSQL_PASSWORD=
- MYSQL_DB=wca_development
networks:
- wca-main
environment:
- MYSQL_HOST=wca_db
- MYSQL_USER=root
- MYSQL_PASSWORD=
- MYSQL_DB=wca_development
10 changes: 8 additions & 2 deletions docker/php-dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
FROM php:5.6.14-fpm
# Targeting 5.6 instead of a specific version is consistent with our current Chef setup
# which in turn targets "php5.6-*" packages in the ondrej repo.
FROM php:5.6-fpm
EXPOSE 9000
COPY './docker/php-fpm.conf' "/usr/local/etc/php-fpm.conf"
COPY './docker/php.ini' "/usr/local/etc/php/php.ini"
COPY './docker/php-mysqli.ini' "/usr/local/etc/php/conf.d/docker-php-ext-mysqli.ini"
RUN docker-php-ext-install mysqli mbstring pdo pdo_mysql
RUN docker-php-ext-install mysql mysqli mbstring pdo pdo_mysql
# configure mysql bindings to use mysqlnd service, which is consistent with our current Chef setup
RUN docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd
RUN docker-php-ext-configure mysql --with-pdo-mysql=mysqlnd
RUN docker-php-ext-configure mysqli --with-pdo-mysql=mysqlnd

0 comments on commit 7eeda13

Please sign in to comment.