Skip to content

Commit 2399402

Browse files
Initialize GitHub codespaces. (#107)
* Init devcontainer * Update comment * PHPCS * Exclude .devcontainer from git archive * Replace call to deprecated user_roles()
1 parent 021a1b0 commit 2399402

File tree

7 files changed

+100
-8
lines changed

7 files changed

+100
-8
lines changed

.devcontainer/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM mcr.microsoft.com/devcontainers/php:1-8.2-bookworm
2+
3+
# Install MariaDB client
4+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5+
&& apt-get install -y mariadb-client \
6+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
7+
8+
# Install php-mysql driver
9+
RUN docker-php-ext-install mysqli pdo pdo_mysql
10+
11+
# Install GD dependencies and extension
12+
RUN apt-get update && apt-get install -y \
13+
libfreetype-dev \
14+
libjpeg62-turbo-dev \
15+
libpng-dev \
16+
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
17+
&& docker-php-ext-install -j$(nproc) gd
18+
19+
# [Optional] Uncomment this section to install additional OS packages.
20+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
21+
# && apt-get -y install --no-install-recommends <your-package-list-here>
22+
23+
# [Optional] Uncomment this line to install global node packages.
24+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
25+

.devcontainer/devcontainer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/php-mariadb
3+
{
4+
"name": "PHP & MariaDB",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "app",
7+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
9+
// Features to add to the dev container. More info: https://containers.dev/features.
10+
// "features": {},
11+
12+
// For use with PHP or Apache (e.g.php -S localhost:8080 or apache2ctl start)
13+
"forwardPorts": [8080, 3306]
14+
15+
// Use 'postCreateCommand' to run commands after the container is created.
16+
// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"
17+
18+
// Configure tool-specific properties.
19+
// "customizations": {},
20+
21+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
22+
// "remoteUser": "root"
23+
}

.devcontainer/docker-compose.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
9+
volumes:
10+
- ../..:/workspaces:cached
11+
12+
# Overrides default command so things don't shut down after the process ends.
13+
command: sleep infinity
14+
15+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
16+
network_mode: service:db
17+
18+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
19+
# (Adding the "ports" property to this file will not forward from a Codespace.)
20+
21+
db:
22+
image: mariadb:10.4
23+
restart: unless-stopped
24+
volumes:
25+
- mariadb-data:/var/lib/mysql
26+
environment:
27+
MYSQL_ROOT_PASSWORD: mariadb
28+
MYSQL_DATABASE: mariadb
29+
MYSQL_USER: mariadb
30+
MYSQL_PASSWORD: mariadb
31+
32+
# Add "forwardPorts": ["3306"] to **devcontainer.json** to forward MariaDB locally.
33+
# (Adding the "ports" property to this file will not forward from a Codespace.)
34+
35+
volumes:
36+
mariadb-data:

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/tests export-ignore
44
/phpunit.xml.dist export-ignore
55
/.phpunit.result.cache export-ignore
6+
/.devcontainer export-ignore

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ updates:
1212
interval: monthly
1313
reviewers:
1414
- richardbporter
15+
- package-ecosystem: devcontainers
16+
directory: "/"
17+
schedule:
18+
interval: monthly

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v4
2121
- name: Start MySQL
2222
run: sudo /etc/init.d/mysql start
23-
- name: Validate composer.json and composer.lock
23+
- name: Validate composer.json
2424
run: composer validate --strict
2525
- name: Install dependencies
2626
run: composer install --prefer-dist --no-scripts --no-suggest --no-interaction

UsersCommands.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Consolidation\OutputFormatters\Options\FormatterOptions;
77
use Consolidation\OutputFormatters\StructuredData\RowsOfFields;
88
use Consolidation\SiteAlias\SiteAliasManagerAwareTrait;
9+
use Drupal\user\Entity\Role;
910
use Drupal\user\Entity\User;
1011
use Drush\Commands\DrushCommands;
1112
use Drush\Drush;
@@ -72,12 +73,14 @@ class UsersCommands extends DrushCommands implements SiteAliasManagerAwareInterf
7273
* @return \Consolidation\OutputFormatters\StructuredData\RowsOfFields
7374
* The users as a RowsOfFields.
7475
*/
75-
public function listAll(array $options = [
76-
'status' => InputOption::VALUE_REQUIRED,
77-
'roles' => InputOption::VALUE_REQUIRED,
78-
'no-roles' => InputOption::VALUE_REQUIRED,
79-
'last-login' => InputOption::VALUE_REQUIRED,
80-
]) {
76+
public function listAll(
77+
array $options = [
78+
'status' => InputOption::VALUE_REQUIRED,
79+
'roles' => InputOption::VALUE_REQUIRED,
80+
'no-roles' => InputOption::VALUE_REQUIRED,
81+
'last-login' => InputOption::VALUE_REQUIRED,
82+
],
83+
) {
8184
// Use an entityQuery to dynamically set property conditions.
8285
$query = \Drupal::entityQuery('user')
8386
->accessCheck(FALSE)
@@ -156,7 +159,7 @@ public function validateList(CommandData $commandData) {
156159
}
157160

158161
// Set the (no-)roles options to an array but validate each one exists.
159-
$actual = user_roles(TRUE);
162+
$actual = Role::loadMultiple();
160163

161164
foreach (['roles', 'no-roles'] as $option) {
162165
if ($roles = $input->getOption($option)) {

0 commit comments

Comments
 (0)