Skip to content

Instantly share code, notes, and snippets.

@ciaranmcnulty
ciaranmcnulty / notes.md
Last active March 25, 2024 06:36
Notes on using Docker on ARM Macs (November 2021)

Docker for Mac

On M1 machines, Docker for Mac is running a lightweight linux ARM VM, then running containers within that, so containers are essentially running natively. Don't be fooled by the fact the UI or binary CLI tools (e.g. docker) might require Rosetta.

Within that VM is an emulation layer called QEmu. This can be used by docker to run Intel containers. This does not use Rosetta at all, and has a roughly 5-6X performance penalty. (If you just upgraded your CPU this may result in a similar performance to your old machine!)

Pulling and running with Docker

Many images in public registries are multi-architecture. For instance at the time of writing on Docker Hub the php:8.0-cli image has the following digests:

@ciaranmcnulty
ciaranmcnulty / cot-statement-fixer.php
Created September 2, 2019 10:56
Script to fix Capital On Tap statements for importing cleanly into Crunch
#! /usr/bin/env php
<?php
$usage = <<<USAGE
Usage:
./cot-statement-fixer starting-balance filename.csv
USAGE;
if (count($argv)!==3){
@ciaranmcnulty
ciaranmcnulty / Dockerfile
Last active June 15, 2023 01:14
PHP Dockerfile with composer target
FROM php:7.2.10-fpm-alpine3.8 AS base
# Stuff needed in all layers
RUN apk add --no-cache gettext fcgi icu-dev
RUN docker-php-ext-install bcmath
FROM base AS dependencies
COPY --from=composer:1.7 /usr/bin/composer /usr/bin/composer
COPY composer.json /app/composer.json
@ciaranmcnulty
ciaranmcnulty / DoctrineUserRepositoryTest.php
Last active March 15, 2019 20:34
Contract tests example
<?php
class DoctrineUserRepositoryTest extends UserRepositoryTest
{
public function setUp()
{
// do something to bootstrap doctrine and set up DB fixtures
$this->userRepository = new DoctrineRepository(/* lots of dependencies */);
}
default:
suites:
foo:
paths: [ %paths.base%/app/modules/fooModule/features ]
contexts: [ Some\Autoloadable\Foo\FeatureContext ]
bar:
paths: [ %paths.base%/app/modules/barModule/features ]
contexts: [ Some\Autoloadable\Bar\FeatureContext ]
<?php
namespace spec\League\Event;
use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use League\Event\EventInterface;
use League\Event\ListenerInterface;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
<?php
class NamedSpec extends ObjectBehavior
{
function it_exposes_the_name_it_is_constructed_with()
{
$this->beConstructedNamed('Foo');
$this->getName()->shouldReturn('Foo');
}
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provider :virtualbox do |vb|
vb.name = "HHVM"
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--ostype", "Ubuntu_64"]
@ciaranmcnulty
ciaranmcnulty / gist:7706c36bbc62ee858317
Created January 13, 2015 20:51
Quick survey of extensions
<?php
$extensions = file_get_contents('https://raw.githubusercontent.com/phpspec/phpspec/master/docs/cookbook/extensions.rst');
$tmp = tempnam(sys_get_temp_dir(), 'extension-checker');
unlink($tmp); mkdir($tmp); chdir($tmp);
if (preg_match_all('/[<](?<url>http.*)[>]/', $extensions, $matches)) {
foreach ($matches['url'] as $url) {
passthru('git clone ' . escapeshellarg($url));

Keybase proof

I hereby claim:

  • I am ciaranmcnulty on github.
  • I am ciaranmcnulty (https://keybase.io/ciaranmcnulty) on keybase.
  • I have a public key whose fingerprint is 72E8 8A58 A8B5 0C9C 3778 3FE1 1BFD AD86 0DC6 FB3B

To claim this, I am signing this object: