Skip to content

Commit 3fc4bed

Browse files
committed
Merge #250 [backport25] Devcontainer on arm with php 8.1
2 parents 89b9d49 + 907c8f2 commit 3fc4bed

14 files changed

+253
-184
lines changed

.devcontainer/Dockerfile

Lines changed: 69 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,87 @@
1-
FROM ubuntu:focal
1+
FROM ubuntu:jammy
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

55
# PHP
6-
RUN apt-get update -y
6+
RUN apt-get update -y && \
7+
apt install -y apache2 vim software-properties-common sudo nano gnupg2
8+
79
RUN apt-get install --no-install-recommends -y \
8-
php7.4 \
9-
php7.4-gd \
10-
php7.4-zip \
11-
php7.4-curl \
12-
php7.4-xml \
13-
php7.4-mbstring \
14-
php7.4-sqlite \
15-
php7.4-xdebug \
16-
php7.4-pgsql \
17-
php7.4-intl \
18-
php7.4-imagick \
19-
php7.4-gmp \
20-
php7.4-apcu \
21-
php7.4-bcmath \
10+
php8.1 \
11+
php8.1-common \
12+
php8.1-gd \
13+
php8.1-zip \
14+
php8.1-curl \
15+
php8.1-xml \
16+
php8.1-xmlrpc \
17+
php8.1-mbstring \
18+
php8.1-sqlite \
19+
php8.1-xdebug \
20+
php8.1-pgsql \
21+
php8.1-intl \
22+
php8.1-imagick \
23+
php8.1-gmp \
24+
php8.1-apcu \
25+
php8.1-bcmath \
26+
php8.1-redis \
27+
php8.1-soap \
28+
php8.1-imap \
29+
php8.1-opcache \
30+
php8.1-cli \
31+
php8.1-dev \
2232
libmagickcore-6.q16-3-extra \
2333
curl \
24-
vim \
2534
lsof \
2635
make \
27-
nodejs \
28-
npm
36+
unzip
37+
38+
# Composer
39+
RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php && \
40+
curl -sS https://composer.github.io/installer.sig -o /tmp/composer-setup.sig && \
41+
php -r "if (hash_file('sha384', '/tmp/composer-setup.php') !== trim(file_get_contents('/tmp/composer-setup.sig'))) { echo 'Composer installation failed, invalid hash'; exit(1); }" && \
42+
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
43+
rm /tmp/composer-setup.php /tmp/composer-setup.sig
2944

30-
RUN echo "xdebug.remote_enable = 1" >> /etc/php/7.4/cli/conf.d/20-xdebug.ini
31-
RUN echo "xdebug.remote_autostart = 1" >> /etc/php/7.4/cli/conf.d/20-xdebug.ini
45+
RUN echo "xdebug.remote_enable = 1" >> /etc/php/8.1/cli/conf.d/20-xdebug.ini && \
46+
echo "xdebug.remote_autostart = 1" >> /etc/php/8.1/cli/conf.d/20-xdebug.ini && \
47+
echo "apc.enable_cli=1" >> /etc/php/8.1/cli/conf.d/20-apcu.ini
48+
49+
# Autostart XDebug for apache
50+
RUN { \
51+
echo "xdebug.mode=debug"; \
52+
echo "xdebug.start_with_request=yes"; \
53+
} >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini
3254

3355
# Docker
3456
RUN apt-get -y install \
3557
apt-transport-https \
3658
ca-certificates \
3759
curl \
60+
jq \
3861
gnupg-agent \
39-
software-properties-common
40-
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
41-
RUN add-apt-repository \
42-
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
62+
software-properties-common && \
63+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
64+
add-apt-repository \
65+
"deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu \
4366
$(lsb_release -cs) \
44-
stable"
45-
RUN apt-get update -y
46-
RUN apt-get install -y docker-ce docker-ce-cli containerd.io
47-
RUN ln -s /var/run/docker-host.sock /var/run/docker.sock
67+
stable" && \
68+
apt-get update -y && \
69+
apt-get install -y docker-ce docker-ce-cli containerd.io && \
70+
ln -s /var/run/docker-host.sock /var/run/docker.sock
71+
72+
# Dedicated DevContainer user runs Apache
73+
ENV APACHE_RUN_USER=devcontainer
74+
ENV APACHE_RUN_GROUP=devcontainer
75+
RUN useradd -ms /bin/bash ${APACHE_RUN_USER} && \
76+
adduser ${APACHE_RUN_USER} sudo && \
77+
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
78+
sed -ri "s/^export APACHE_RUN_USER=.*$/export APACHE_RUN_USER=${APACHE_RUN_USER}/" "/etc/apache2/envvars" && \
79+
sed -ri "s/^export APACHE_RUN_GROUP=.*$/export APACHE_RUN_GROUP=${APACHE_RUN_GROUP}/" "/etc/apache2/envvars"
80+
81+
USER devcontainer
82+
83+
# NVM
84+
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
85+
RUN bash --login -i -c 'source /home/devcontainer/.bashrc && nvm install 16'
86+
87+
WORKDIR /var/www/html

.devcontainer/apps.config.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
$CONFIG = array (
3+
'apps_paths' => array (
4+
0 => array (
5+
'path' => OC::$SERVERROOT.'/customapps',
6+
'url' => '/customapps',
7+
'writable' => true,
8+
),
9+
1 => array (
10+
'path' => OC::$SERVERROOT.'/apps',
11+
'url' => '/apps',
12+
'writable' => true,
13+
),
14+
),
15+
);

.devcontainer/codespace.config.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
<?php
22

3-
$cloudEnvironmentId = getenv('CLOUDENV_ENVIRONMENT_ID');
3+
$codespaceName = getenv('CODESPACE_NAME');
4+
$codespaceDomain = getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN');
45

56
$CONFIG = [
67
'mail_from_address' => 'no-reply',
78
'mail_smtpmode' => 'smtp',
89
'mail_sendmailmode' => 'smtp',
910
'mail_domain' => 'example.com',
10-
'mail_smtphost' => 'localhost',
11+
'mail_smtphost' => 'mailhog',
1112
'mail_smtpport' => '1025',
1213
'memcache.local' => '\OC\Memcache\APCu',
1314
];
1415

15-
if($cloudEnvironmentId !== true) {
16-
$CONFIG['overwritehost'] = $cloudEnvironmentId . '-80.apps.codespaces.githubusercontent.com';
16+
if(is_string($codespaceName) && !empty($codespaceName) && is_string($codespaceDomain) && !empty($codespaceDomain)) {
17+
$host = $codespaceName . '-80.' . $codespaceDomain;
18+
$CONFIG['overwritehost'] = $host;
19+
$CONFIG['overwrite.cli.url'] = 'https://' . $host;
1720
$CONFIG['overwriteprotocol'] = 'https';
21+
$CONFIG['trusted_domains'] = [ $host ];
1822
}

.devcontainer/devcontainer.json

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@
88
8080,
99
8025
1010
],
11-
"runArgs": [
12-
"--privileged"
13-
],
14-
"extensions": [
15-
"felixfbecker.php-debug",
16-
"felixfbecker.php-intellisense",
17-
"ms-azuretools.vscode-docker"
18-
],
19-
"settings": {
20-
"php.suggest.basic": false,
21-
}
11+
"customizations": {
12+
"vscode": {
13+
"extensions": [
14+
"felixfbecker.php-debug",
15+
"felixfbecker.php-intellisense",
16+
"ms-azuretools.vscode-docker",
17+
"xdebug.php-debug",
18+
"donjayamanne.githistory"
19+
],
20+
"settings": {
21+
"php.suggest.basic": false
22+
}
23+
}
24+
},
25+
"workspaceFolder": "/var/www/html",
26+
"remoteUser": "devcontainer"
2227
}

.devcontainer/docker-compose.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,49 @@ services:
55
volumes:
66
- .:/workspace:cached
77
- /var/run/docker.sock:/var/run/docker-host.sock
8-
command: /bin/sh -c "while sleep 1000; do :; done"
8+
- ..:/var/www/html
9+
- ../../customapps:/var/www/html/customapps
10+
- ../../data:/var/www/html/data
11+
- ../../config:/var/www/html/config
12+
command: /var/www/html/.devcontainer/entrypoint.sh
913
ports:
1014
- 80:80
11-
- 8080:8080
12-
- 8025:8025
13-
15+
depends_on:
16+
db:
17+
condition: service_healthy
18+
mailhog:
19+
condition: service_started
20+
1421
db:
1522
image: postgres
1623
restart: always
1724
environment:
1825
POSTGRES_PASSWORD: postgres
19-
network_mode: service:nextclouddev
20-
26+
PGDATA: /data/postgres
27+
volumes:
28+
- ../../data/db:/data/postgres
29+
expose:
30+
- "5432"
31+
healthcheck:
32+
test: ["CMD-SHELL", "pg_isready"]
33+
interval: 10s
34+
timeout: 5s
35+
retries: 10
36+
37+
2138
adminer:
2239
image: adminer
2340
restart: always
24-
network_mode: service:nextclouddev
41+
ports:
42+
- 8080:8080
43+
depends_on:
44+
db:
45+
condition: service_healthy
2546

2647
mailhog:
2748
image: mailhog/mailhog
2849
restart: always
29-
network_mode: service:nextclouddev
50+
ports:
51+
- 8025:8025
52+
53+

.devcontainer/entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
sudo service apache2 start
4+
5+
while sleep 1000; do :; done

.devcontainer/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Listen for Xdebug",
9+
"type": "php",
10+
"request": "launch",
11+
"port": 9003
12+
}
13+
]
14+
}

.devcontainer/lock.config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
$CONFIG = array (
3+
'config_is_read_only' => true,
4+
);

.devcontainer/nmc.config.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$CONFIG = array (
3+
'htaccess.RewriteBase' => '/',
4+
'default_language' => 'de_DE',
5+
'integrity.check.disabled' => true, // not recommended for prod, but for customisation
6+
'auth.authtoken.v1.disabled' => true,
7+
'sharing.force_share_accept' => true,
8+
'status-email-message-provider' => '\\OCA\\EmailTemplateExample\\MessageProvider',
9+
'mail_template_class' => 'OCA\\EmailTemplateExample\\EMailTemplate',
10+
// "logfile_office_report" => "/var/log/nextcloud/office.log",
11+
);

.devcontainer/nmcsetup.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" >/dev/null 2>&1 && pwd )"
3+
4+
cd $DIR/
5+
6+
# after installation, do some MagentaCLOUD specific setups to start closer to production
7+
8+
# customapps directory split
9+
cp .devcontainer/apps.config.php config/apps.config.php
10+
cp .devcontainer/nmc.config.php config/nmc.config.php
11+
12+
# disable user themeing
13+
sudo -u ${APACHE_RUN_USER} php occ theming:config disable-user-theming yes
14+
15+
# fixed themeing for MagentaCLOUD
16+
cp .devcontainer/theme.config.php config/theme.config.php
17+
18+
# refresh .htaccess for short URL notation
19+
sudo -u ${APACHE_RUN_USER} php occ maintenance:update:htaccess
20+
21+
# "Organisational" setting
22+
sudo -u ${APACHE_RUN_USER} php occ theming:config color "#e20074" # don't use uppercase letters!
23+
sudo -u ${APACHE_RUN_USER} php occ theming:config name MagentaCLOUD
24+
sudo -u ${APACHE_RUN_USER} php occ theming:config slogan "Alle Dateien sicher an einem Ort"
25+
sudo -u ${APACHE_RUN_USER} php occ theming:config imprintUrl "http://www.telekom.de/impressum"
26+
sudo -u ${APACHE_RUN_USER} php occ theming:config privacyUrl "https://static.magentacloud.de/Datenschutz"
27+
28+
# app settings
29+
sudo -u ${APACHE_RUN_USER} php occ config:app:set theming AndroidClientUrl --value \
30+
"https://play.google.com/store/apps/details?=com.t_systems.android.webdav"
31+
sudo -u ${APACHE_RUN_USER} php occ config:app:set theming iTunesAppId --value "312838242"
32+
sudo -u ${APACHE_RUN_USER} php occ config:app:set theming iOSClientUrl --value \
33+
"https://apps.apple.com/us/app/magentacloud-cloud-speicher/id312838242"
34+
35+
# enable/disable apps
36+
sudo -u ${APACHE_RUN_USER} php occ app:enable nmctheme
37+
sudo -u ${APACHE_RUN_USER} php occ app:disable dashboard # may remove as soon as dashboard CR is implemented
38+
39+
# there are side effects when using devcontainer and
40+
# doing the main settings via webapp. For the moment, the best
41+
# workaround is to lock config and avoid overwrite by nextcloud
42+
# esp. on container rebuild
43+
cp .devcontainer/lock.config.php config/lock.config.php

.devcontainer/setup.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,35 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" >/dev/null 2>&1 && pwd )"
44
cd $DIR/
55
git submodule update --init
66

7-
# Codespace config
7+
# VSCode debugger profile
8+
mkdir -p .vscode && cp .devcontainer/launch.json .vscode/launch.json
9+
10+
# Onetime installation setup
11+
if [[ ! $(sudo -u ${APACHE_RUN_USER} php occ status) =~ installed:[[:space:]]*true ]]; then
12+
echo "Running NC installation"
13+
14+
# we could be faced with an externalized, empty config dir
15+
touch config/CAN_INSTALL
16+
17+
# this produces the plain config file without any overwriting
18+
sudo -u ${APACHE_RUN_USER} php occ maintenance:install \
19+
--verbose \
20+
--database=pgsql \
21+
--database-name=postgres \
22+
--database-host=db \
23+
--database-port=5432 \
24+
--database-user=postgres \
25+
--database-pass=postgres \
26+
--admin-user admin \
27+
--admin-pass admin
28+
fi
29+
30+
# Codespace config; do it late to avoid duplication into config.php
31+
# (which removed the conditional code!)
32+
# may consider setting 'config_is_read_only' => true,
833
cp .devcontainer/codespace.config.php config/codespace.config.php
34+
35+
# add MagentaCLOUD convenience setup
36+
source .devcontainer/nmcsetup.sh
37+
38+
sudo service apache2 restart

.devcontainer/theme.config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
$CONFIG = array (
3+
'enforce_theme' => 'default', // or any other theme contained in the app
4+
'theme' => '', // disable old themeing
5+
);

0 commit comments

Comments
 (0)