Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM partdb-dev:local

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=${USER_UID}

RUN groupadd --gid "${USER_GID}" "${USERNAME}" \
&& useradd --uid "${USER_UID}" --gid "${USER_GID}" --create-home --shell /bin/bash "${USERNAME}" \
&& usermod --append --groups www-data "${USERNAME}" \
&& printf '%s ALL=(root) NOPASSWD:ALL\n' "${USERNAME}" > "/etc/sudoers.d/${USERNAME}" \
&& chmod 0440 "/etc/sudoers.d/${USERNAME}"

COPY .devcontainer/apache-ssl.conf /etc/apache2/sites-available/partdb-dev-ssl.conf

RUN mkdir -p /etc/apache2/ssl \
&& openssl req -x509 -newkey rsa:2048 -nodes -days 825 \
-keyout /etc/apache2/ssl/partdb-dev.key \
-out /etc/apache2/ssl/partdb-dev.crt \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1,IP:::1" \
&& chmod 0600 /etc/apache2/ssl/partdb-dev.key \
&& a2enmod ssl \
&& a2ensite partdb-dev-ssl

EXPOSE 443
25 changes: 25 additions & 0 deletions .devcontainer/apache-ssl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName localhost
ServerAdmin admin@localhost
DocumentRoot /var/www/html/public

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/partdb-dev.crt
SSLCertificateKeyFile /etc/apache2/ssl/partdb-dev.key

<Directory /var/www/html/public>
AllowOverride All
Require all granted
</Directory>

<Directory /var/www/html/public/media>
<FilesMatch "(?i)\.(php[3-8]?|phar|phtml|pht|phps)$">
Require all denied
</FilesMatch>
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
</IfModule>
59 changes: 59 additions & 0 deletions .devcontainer/compose.devcontainer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
services:
setup:
image: partdb-devcontainer:local
pull_policy: never
user: vscode
entrypoint: []
working_dir: /var/www/html
environment:
HOME: /home/vscode
COMPOSER_HOME: /home/vscode/.composer
COMPOSER_CACHE_DIR: /home/vscode/.cache/composer
YARN_CACHE_FOLDER: /home/vscode/.cache/yarn
APP_ENV: dev
APP_DEBUG: "1"
DATABASE_URL: "sqlite:///%kernel.project_dir%/var/db/app.db"
APP_SECRET: "partdb-development-secret"
DEFAULT_LANG: en
DEFAULT_TIMEZONE: UTC
BASE_CURRENCY: USD
INSTANCE_NAME: "Part-DB Development"
CHECK_FOR_UPDATES: "0"
USE_GRAVATAR: "0"
ALLOW_ATTACHMENT_DOWNLOADS: "0"
volumes:
- .:/var/www/html
- ./public/media:/var/www/html/public/media
- ./uploads:/var/www/html/uploads
command:
- sh
- -lc
- >-
composer install
&& php bin/console about
&& yarn install --network-timeout 600000
&& yarn build
&& php bin/console doctrine:migrations:migrate --no-interaction
restart: "no"

partdb:
build:
context: .
dockerfile: .devcontainer/Dockerfile
image: partdb-devcontainer:local
ports:
- "8443:443"
volumes:
- ./public/media:/var/www/html/public/media
- ./uploads:/var/www/html/uploads
depends_on:
setup:
condition: service_completed_successfully

assets:
volumes:
- ./public/media:/var/www/html/public/media
- ./uploads:/var/www/html/uploads
depends_on:
setup:
condition: service_completed_successfully
28 changes: 28 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "Part-DB Development",
"initializeCommand": "docker build --file Dockerfile --tag partdb-local-dev-base . && docker compose --file compose.dev.yaml build partdb",
"dockerComposeFile": [
"../compose.dev.yaml",
"compose.devcontainer.yaml"
],
"service": "partdb",
"runServices": [
"partdb",
"assets"
],
"workspaceFolder": "/var/www/html",
"remoteUser": "vscode",
"updateRemoteUserUID": true,
"overrideCommand": false,
"shutdownAction": "stopCompose",
"portsAttributes": {
"80": {
"label": "Part-DB HTTP",
"onAutoForward": "ignore"
},
"443": {
"label": "Part-DB HTTPS",
"onAutoForward": "ignore"
}
}
}
6 changes: 4 additions & 2 deletions .docker/dev/dev-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ prepare_runtime()
"$APP_DIR/uploads" \
"$APP_DIR/public/media" \
"$APP_DIR/public/build" \
"$APP_DIR/public/bundles"
"$APP_DIR/public/bundles" \
"$APP_DIR/public/kicad"

chown -R www-data:www-data "$DEV_HOME"

Expand All @@ -39,7 +40,8 @@ prepare_runtime()
"$APP_DIR/uploads" \
"$APP_DIR/public/media" \
"$APP_DIR/public/build" \
"$APP_DIR/public/bundles"
"$APP_DIR/public/bundles" \
"$APP_DIR/public/kicad"

export HOME="$DEV_HOME"
export COMPOSER_HOME="$DEV_HOME/.composer"
Expand Down
22 changes: 22 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ git clone https://github.com/Part-DB/Part-DB-server.git
cd Part-DB-server
```

### Visual Studio Code Dev Container

The first setup can take several minutes. When it finishes, open either:

```
http://localhost:8080/
https://localhost:8443/
```

The HTTPS endpoint uses a self-signed development certificate. Your browser will show a certificate warning until you explicitly accept the certificate or add it to your local trust store. The command-line Docker setup only exposes HTTP.

During the first database migration an administrator account is created. To retrieve its generated password, open a local terminal and inspect the setup service logs:

```bash
docker compose -f compose.dev.yaml \
-f .devcontainer/compose.devcontainer.yaml logs setup
```

The automatic setup runs again when the Dev Container is rebuilt. Docker, Composer, and Yarn reuse their caches, and database migrations only apply migrations that have not already run.

### Command-line Setup

Build the upstream production base image:

```bash
Expand Down