Skip to content

Commit 0675391

Browse files
authored
Merge pull request #1363 from UnionOfRAD/devcontainer-php81
upgrades devcontainer to php 8.1
2 parents 082b9b8 + 3494175 commit 0675391

File tree

7 files changed

+923
-0
lines changed

7 files changed

+923
-0
lines changed

.devcontainer/Dockerfile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Note: You can use any Debian/Ubuntu based image you want.
2+
FROM php:8-cli-bullseye
3+
4+
# [Option] Install zsh
5+
ARG INSTALL_ZSH="true"
6+
# [Option] Upgrade OS packages to their latest versions
7+
ARG UPGRADE_PACKAGES="false"
8+
# [Option] Enable non-root Docker access in container
9+
ARG ENABLE_NONROOT_DOCKER="true"
10+
# [Option] Use the OSS Moby CLI instead of the licensed Docker CLI
11+
ARG USE_MOBY="true"
12+
13+
# Enable new "BUILDKIT" mode for Docker CLI
14+
ENV DOCKER_BUILDKIT=1
15+
16+
# Install needed packages and setup non-root user. Use a separate RUN statement to add your
17+
# own dependencies. A user of "automatic" attempts to reuse an user ID if one already exists.
18+
ARG USERNAME=automatic
19+
ARG USER_UID=1000
20+
ARG USER_GID=$USER_UID
21+
COPY library-scripts/*.sh /tmp/library-scripts/
22+
RUN apt-get update \
23+
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
24+
# Use Docker script from script library to set things up
25+
&& /bin/bash /tmp/library-scripts/docker-debian.sh "${ENABLE_NONROOT_DOCKER}" "/var/run/docker-host.sock" "/var/run/docker.sock" "${USERNAME}" \
26+
# Clean up
27+
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts/
28+
29+
# Setting the ENTRYPOINT to docker-init.sh will configure non-root access
30+
# to the Docker socket. The script will also execute CMD as needed.
31+
ENTRYPOINT [ "/usr/local/share/docker-init.sh" ]
32+
CMD [ "sleep", "infinity" ]
33+
34+
# [Optional] Uncomment this section to install additional OS packages.
35+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
36+
# && apt-get -y install --no-install-recommends vim
37+
38+
COPY *.sh /tmp/
39+
RUN /tmp/build.sh

.devcontainer/build.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#/bin/bash
2+
3+
apt-get update && export DEBIAN_FRONTEND=noninteractive \
4+
&& apt-get -y install --no-install-recommends curl default-mysql-client git libicu-dev libmemcached-dev libmcrypt-dev libpq-dev libssl-dev netcat postgresql-client-13 vim zip zlib1g-dev
5+
6+
pecl install apcu memcached mongodb opcache redis xdebug
7+
docker-php-ext-install intl pdo pdo_mysql pdo_pgsql
8+
docker-php-ext-enable mongodb redis
9+
10+
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini
11+
echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/xdebug.ini
12+
echo "extension=$(find /usr/local/lib/php/extensions/ -name apcu.so)" > /usr/local/etc/php/conf.d/apcu.ini
13+
echo "extension=$(find /usr/local/lib/php/extensions/ -name memcached.so)" > /usr/local/etc/php/conf.d/memcached.ini
14+
15+
/tmp/install-composer.sh

.devcontainer/devcontainer.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/docker-from-docker-compose
3+
{
4+
"name": "Docker from Docker Compose",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "app",
7+
"workspaceFolder": "/workspace",
8+
9+
// Use this environment variable if you need to bind mount your local source code into a new container.
10+
"remoteEnv": {
11+
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
12+
},
13+
14+
// Set *default* container specific settings.json values on container create.
15+
"settings": {},
16+
17+
// Add the IDs of extensions you want installed when the container is created.
18+
"extensions": [
19+
"ms-azuretools.vscode-docker"
20+
],
21+
22+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
23+
// "forwardPorts": [],
24+
25+
// Use 'postCreateCommand' to run commands after the container is created.
26+
// "postCreateCommand": "docker --version",
27+
28+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
29+
"remoteUser": "vscode"
30+
}

.devcontainer/docker-compose.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version: '3'
2+
3+
services:
4+
mysql:
5+
image: mysql:5
6+
command: mysqld --sql_mode="" --default-authentication-plugin=mysql_native_password
7+
environment:
8+
MYSQL_ROOT_PASSWORD: password
9+
ports:
10+
- 3306:3306
11+
redis:
12+
image: redis:4
13+
ports:
14+
- 6379:6379
15+
mongo:
16+
image: mongo
17+
ports:
18+
- 27017:27017
19+
memcached:
20+
image: memcached
21+
ports:
22+
- 11211:11211
23+
couchdb:
24+
image: couchdb:2
25+
ports:
26+
- 5984:5984
27+
postgres:
28+
image: postgres
29+
environment:
30+
POSTGRES_HOST_AUTH_METHOD: trust
31+
ports:
32+
- 5432:5432
33+
app:
34+
build:
35+
context: .
36+
dockerfile: Dockerfile
37+
38+
volumes:
39+
# Forwards the local Docker socket to the container.
40+
- /var/run/docker.sock:/var/run/docker-host.sock
41+
# Update this to wherever you want VS Code to mount the folder of your project
42+
- ..:/workspace:cached
43+
44+
# Overrides default command so things don't shut down after the process ends.
45+
entrypoint: /usr/local/share/docker-init.sh
46+
command: sleep infinity
47+
48+
# Uncomment the next four lines if you will use a ptrace-based debuggers like C++, Go, and Rust.
49+
# cap_add:
50+
# - SYS_PTRACE
51+
# security_opt:
52+
# - seccomp:unconfined
53+
54+
# Uncomment the next line to use a non-root user for all processes.
55+
# user: vscode
56+
57+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
58+
# (Adding the "ports" property to this file will not forward from a Codespace.)

.devcontainer/install-composer.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
4+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
5+
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
6+
7+
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
8+
then
9+
>&2 echo 'ERROR: Invalid installer checksum'
10+
rm composer-setup.php
11+
exit 1
12+
fi
13+
14+
php composer-setup.php --quiet
15+
RESULT=$?
16+
rm composer-setup.php
17+
mv composer.phar /usr/local/bin/composer
18+
exit $RESULT

0 commit comments

Comments
 (0)