Skip to content

Commit

Permalink
dev: Vagrant to Docker migration (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
LastDragon-ru authored Apr 7, 2024
2 parents 8a175c4 + 57fd23a commit 916f5ab
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 294 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ Thumbs.db

# Project
/composer.lock
/Vagrant.yml
/compose.yaml
86 changes: 86 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Build
# ==============================================================================
FROM ubuntu:jammy AS build

# System
# ------------------------------------------------------------------------------

RUN apt update && apt upgrade -y

RUN apt install -y \
software-properties-common \
curl \
git \
""

# PHP
# ------------------------------------------------------------------------------
RUN <<EOF
set -eux

PHP_VERSION=8.3
PHP_CONFIG="/etc/php/${PHP_VERSION}"

LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
DEBIAN_FRONTEND=noninteractive TZ=UTC apt install -y \
"php${PHP_VERSION}-cli" \
"php${PHP_VERSION}-common" \
"php${PHP_VERSION}-mbstring" \
"php${PHP_VERSION}-bcmath" \
"php${PHP_VERSION}-zip" \
"php${PHP_VERSION}-intl" \
"php${PHP_VERSION}-xml" \
"php${PHP_VERSION}-xdebug" \
"php${PHP_VERSION}-curl" \
"php${PHP_VERSION}-pdo-sqlite" \
""

sed -i 's/^error_reporting = .\+$/error_reporting = E_ALL/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^display_errors = .\+$/display_errors = On/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^;opcache\.enable=.\+$/opcache.enable=1/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^;opcache\.enable_cli=.\+$/opcache.enable_cli=1/' "${PHP_CONFIG}/cli/php.ini"
tee -a "${PHP_CONFIG}/mods-available/xdebug.ini" > /dev/null <<"EOT"
xdebug.output_dir = /project/.xdebug
xdebug.profiler_output_name = callgrind.out.%t.%r
xdebug.client_host = host.docker.internal
xdebug.mode = debug
xdebug.start_with_request = trigger
EOT
EOF

# Composer
# ------------------------------------------------------------------------------
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
RUN <<EOF
set -eux
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"

if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
fi

php composer-setup.php --quiet --install-dir=/usr/local/bin --filename=composer
RESULT=$?
rm composer-setup.php
exit $RESULT
EOF

# Npm
# ------------------------------------------------------------------------------
# https://github.com/nodesource/distributions
RUN <<EOF
set -eux
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash
apt install -y nodejs
EOF

# Scratch
# ==============================================================================
FROM scratch
COPY --from=build / /
CMD "/bin/bash"
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ Please follow [Upgrade Guide](UPGRADE.md).
[//]: # (start: a974316bcb5b40e0fcedb0c38b2c3c43c80c2cadfbf95a8caf27d6f163abff0d)
[//]: # (warning: Generated automatically. Do not edit.)

# Development

1. Fork & clone
2. `docker compose up`
3. ...
4. Enjoy

# Legend

| Icon | Place | Description |
Expand Down
47 changes: 0 additions & 47 deletions Vagrant.example.yml

This file was deleted.

Loading

0 comments on commit 916f5ab

Please sign in to comment.