Skip to content

Add a Docker based development environment#5

Draft
gjnoonan wants to merge 4 commits into
julmud:mainfrom
gjnoonan:dev-environment
Draft

Add a Docker based development environment#5
gjnoonan wants to merge 4 commits into
julmud:mainfrom
gjnoonan:dev-environment

Conversation

@gjnoonan
Copy link
Copy Markdown
Contributor

@gjnoonan gjnoonan commented Jan 6, 2020

Whilst this works, and is what I have been running locally, it is not quite ready to go into master yet; I still need to rebase and split out the commits. However I thought I would push this up as a draft to allow people to raise comment/suggestions.

I've used alpine as the container as it is lightweight and produces a nice small image and is generally really good for this application. The main error that comes up at the moment is:

Notice: iconv(): Wrong charset, conversion from `ISO-8859-1' to `ascii//TRANSLIT' is not allowed in /var/www/functions.php on line 1033

Warning: Cannot modify header information - headers already sent by (output started at /var/www/functions.php:1033) in /var/www/index.php on line 2884

I know why the first one errs and the second one can be ignored as it only displays because of the first. At the moment it doesn't stop anything from working. I may switch alpine out for debian if it proves a pain

I've added a Makefile for convenience, I realise that a Powershell file may need to be included too (or indeed a VSCode .devcontainer) for those running windows, but I've had no chance to write/test one.

When you first clone the project and run make install it will

  1. copy the env.example file to .env
    2)Build the docker containers. unless you have deleted the image, it has changed, or you have run reset this will only happen the first time and will be quite slow.
  2. start all the containers in the background.

From here all you need to do is visit the webpage via port 8080, upload your Collection.XML via the usual method and then everything is ready to go. You can edit your PHP files locally and the changes will be reflected.

during development you should not have to run make install again, just use make start and make stop

MySQL will automatically create the database, and run schema.sql to set-up the required structure once the container has been started.

If you don't want to, or can't run the Makefile then you can run the steps manually:

  1. docker pull --parallel
  2. docker build --no-cache --pull (the pull here makes sure you have the latest base image and won't use the local one if it exists)
  3. docker-compose up
  4. profit

On a side note, as part of another patch series/MR I would like introduce a standard Collection.xml fixture into the database to use for development. I have one that I used locally when developing #2. This contains a few Blu-Rays and UltraHD titles; However, if we add a DVD, HD-DVD, as well as a release or two in non-english languages we should have enough to make sure nothing is breaking :-)

note: If you would like to test this out, in your localsiteconfig.php file set $dbhost = 'db';

this wall of text will be cleaned up into something more cohesive before it is taken out of draft

Comment thread Dockerfile
@julmud
Copy link
Copy Markdown
Owner

julmud commented Jan 7, 2020 via email

@julmud
Copy link
Copy Markdown
Owner

julmud commented Jan 17, 2020

I've made a configuration which adds:

  • xdebug to the app container
  • a fix for the missing iconv library
  • a VSCode .devcontainer which enables debugging directly from VSCode

Shall I simply push my commits to this branch and merge request?

(Alas, I'm having some trouble with line endings to be able to easily run git from the containers and VSCode...)

@gjnoonan
Copy link
Copy Markdown
Contributor Author

Sorry @julmud, it has been a busy week, I've not found as much "free" time as I'd hoped.

My Local branch also fixes the iconv issue. Good to hear you did the .devcontainer, I also started that but did not get it to a point where I was happy with it.

Yep please either push to the branch or send me the patches. I will rebase the commits and provide correct attribution before we merge.

@julmud
Copy link
Copy Markdown
Owner

julmud commented Jan 20, 2020

@gjnoonan I've been unsuccessful in pushing directly the commits to your branch or this pull request, so I've sent you an email with the patches. ;-)

@gjnoonan gjnoonan force-pushed the dev-environment branch 2 times, most recently from 0b0d7a6 to 17b9fd5 Compare January 20, 2020 19:19
@gjnoonan
Copy link
Copy Markdown
Contributor Author

@julmud I reviewed your patches earlier, via email :-) if you could rebase against my latest push then they should apply cleanly.

@gjnoonan gjnoonan force-pushed the dev-environment branch 2 times, most recently from 179134e to 1821d21 Compare January 20, 2020 19:22
@julmud
Copy link
Copy Markdown
Owner

julmud commented Jan 21, 2020

@julmud I reviewed your patches earlier, via email :-) if you could rebase against my latest push then they should apply cleanly.

@gjnoonan Is it normal that the docker-compose.yml file is missing from your latest commits? And the .env.example file seems to be missing too.

@gjnoonan gjnoonan force-pushed the dev-environment branch 2 times, most recently from 4de1269 to 35ef303 Compare January 21, 2020 07:52
@gjnoonan
Copy link
Copy Markdown
Contributor Author

@julmud I reviewed your patches earlier, via email :-) if you could rebase against my latest push then they should apply cleanly.

@gjnoonan Is it normal that the docker-compose.yml file is missing from your latest commits? And the .env.example file seems to be missing too.

hmm sorry about that, I must not have paid enough attention after my last rebase.

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 2 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jan 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

gjnoonan and others added 4 commits May 11, 2025 07:24
To aid with development speed, as well as to ensure consistency, a
standardised development environment has been created.

We also provide a Makefile to take some more pain away which provides
the following targeets:

  * `make install` - create .env, download dependencies, create the db, start
	everything up
  * `make start`  - start the environment
  * `make stop`   - tear it all down
  * `make reset` kill all the containers and run `install`

Signed-off-by: Gavin-John Noonan <[email protected]>
With the default alpine image, the iconv library is wrongly configured,
resulting in a PHP notice (iconv(): Wrong charset, conversion from
`ISO-8859-1' to `ascii//TRANSLIT' is not allowed in
/var/www/functions.php on line 1033) when running an update. Adding the
GNU libiconv library to the image solves this problem.
The devcontainer allows us to run everything directly in containers
from the Visual Studio Code GUI. Adding git to the base image, so that
all version control operations can be done directly when running the
containers from Visual Studio Code.
For easier debugging with Visual Studio Code, add the
xdebug extension to the PHP installation, and a configuration
for debugging the project from the GUI. Note that xdebug
connects to port 9229, as the default port of 9000 is
already being used by php-fpm.
@julmud julmud force-pushed the dev-environment branch from ceeee71 to eeb48ba Compare May 11, 2025 05:24
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
5 Security Hotspots

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants