Skip to content

Commit

Permalink
Merge pull request #492 from lanedirt/190-add-postgresql-as-database-…
Browse files Browse the repository at this point in the history
…option-to-prevent-concurrency-locking-due-to-sqlite-limitations

Switch SQLite to PostgreSQL database engine
  • Loading branch information
lanedirt authored Dec 29, 2024
2 parents d39ecf6 + 1151089 commit 3263360
Show file tree
Hide file tree
Showing 173 changed files with 6,738 additions and 988 deletions.
15 changes: 14 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,17 @@
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
README.md

# Exclude AliasVault data directories
database/
logs/
certificates/

# Exclude git directory
.git/

# Exclude development files
*.log
*.env
*.env.*
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ ADMIN_PASSWORD_GENERATED=2024-01-01T00:00:00Z
PRIVATE_EMAIL_DOMAINS=
SMTP_TLS_ENABLED=false
LETSENCRYPT_ENABLED=false
POSTGRES_PASSWORD=
SUPPORT_EMAIL=
3 changes: 3 additions & 0 deletions .github/workflows/dotnet-e2e-admin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- name: Build
run: dotnet build

- name: Start dev database
run: ./install.sh configure-dev-db start

- name: Ensure browsers are installed
run: pwsh src/Tests/AliasVault.E2ETests/bin/Debug/net9.0/playwright.ps1 install --with-deps

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dotnet-e2e-client-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Build
run: dotnet build

- name: Start dev database
run: ./install.sh configure-dev-db start

- name: Ensure browsers are installed
run: pwsh src/Tests/AliasVault.E2ETests/bin/Debug/net9.0/playwright.ps1 install --with-deps

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dotnet-e2e-misc-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- name: Build
run: dotnet build

- name: Start dev database
run: ./install.sh configure-dev-db start

- name: Ensure browsers are installed
run: pwsh src/Tests/AliasVault.E2ETests/bin/Debug/net9.0/playwright.ps1 install --with-deps

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dotnet-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ jobs:
- name: Build
run: dotnet build

- name: Start dev database
run: ./install.sh configure-dev-db start

- name: Run integration tests
run: dotnet test src/Tests/AliasVault.IntegrationTests --no-build --verbosity normal
24 changes: 16 additions & 8 deletions .github/workflows/publish-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}

- name: Build and push Postgres image
uses: docker/build-push-action@v5
with:
context: .
file: src/Databases/AliasServerDb/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-postgres:latest,${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-postgres:${{ github.ref_name }}

- name: Build and push API image
uses: docker/build-push-action@v5
with:
Expand All @@ -62,6 +70,14 @@ jobs:
push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-admin:latest,${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-admin:${{ github.ref_name }}

- name: Build and push Reverse Proxy image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-reverse-proxy:latest,${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-reverse-proxy:${{ github.ref_name }}

- name: Build and push SMTP image
uses: docker/build-push-action@v5
with:
Expand All @@ -78,14 +94,6 @@ jobs:
push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-task-runner:latest,${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-task-runner:${{ github.ref_name }}

- name: Build and push Reverse Proxy image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-reverse-proxy:latest,${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-reverse-proxy:${{ github.ref_name }}

- name: Build and push InstallCli image
uses: docker/build-push-action@v5
with:
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ ServiceFabricBackup/
*.sqlite-shm
*.sqlite-wal

# SQL files
*.sql
*.sql.gz

# Business Intelligence projects
*.rdl.data
*.bim.layout
Expand Down Expand Up @@ -407,3 +411,7 @@ certificates/letsencrypt/**
docs/_site
docs/vendor
docs/.bundle

# Database files
database/postgres
database/postgres-dev
29 changes: 21 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ cp .github/hooks/commit-msg .git/hooks/commit-msg
chmod +x .git/hooks/commit-msg
```

### 3. Install the latest version of .NET SDK 8
### 3. Install the latest version of .NET SDK 9

```bash
# Install .NET SDK 8
# Install .NET SDK 9

# On MacOS via brew:
brew install --cask dotnet-sdk

# On Windows via winget
winget install Microsoft.DotNet.SDK.8
winget install Microsoft.DotNet.SDK.9
```

### 4. Install dotnet CLI EF Tools
Expand All @@ -51,13 +51,26 @@ export PATH="$PATH:$HOME/.dotnet/tools"
dotnet ef
```

### 5. Run Tailwind CSS compiler while changing HTML files to update compiled CSS
### 5. Install dev database
AliasVault uses PostgreSQL as its database. In order to run the project locally from Visual Studio / Rider you will need to install the dev database. You can do this
by running the following command. This will start a separate PostgreSQL instance on port 5433 accessible via the `localhost:5433` address.

```bash
npm run build:css
./install.sh configure-dev-db
```

### 6. Install Playwright in order to locally run NUnit E2E (end-to-end) tests
This will start the dev database and create a new database for the project.

### 6. Run Tailwind CSS compiler when changing HTML files to update compiled CSS

```bash
# For Admin project (in the admin project directory)
npm run build:admin-css
# For Client project (in the client project directory)
npm run build:client-css
```

### 7. Install Playwright in order to locally run NUnit E2E (end-to-end) tests

```bash
# First install PowerShell for Mac (if you don't have it already)
Expand All @@ -66,10 +79,10 @@ brew install powershell/tap/powershell
dotnet tool install --global Microsoft.Playwright.CLI
# Run Playwright install script to download local browsers
# Note: make sure the E2E test project has been built at least once so the bin dir exists.
pwsh src/Tests/AliasVault.E2ETests/bin/Debug/net8.0/playwright.ps1 install
pwsh src/Tests/AliasVault.E2ETests/bin/Debug/net9.0/playwright.ps1 install
```

### 7. Create AliasVault.Client appsettings.Development.json
### 8. Create AliasVault.Client appsettings.Development.json
The WASM client app supports a development specific appsettings.json file. This appsettings file is optional but can override various options to make debugging easier.


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ This method uses pre-built Docker images and works on minimal hardware specifica

- Linux VM with root access (Ubuntu or RHEL based distros recommended)
- 1 vCPU
- 512MB RAM
- 1GB RAM
- 16GB disk space
- Docker installed

Expand Down
12 changes: 9 additions & 3 deletions docker-compose.build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
services:
reverse-proxy:
image: aliasvault-reverse-proxy
postgres:
image: aliasvault-postgres
build:
context: .
dockerfile: Dockerfile
dockerfile: src/Databases/AliasServerDb/Dockerfile

client:
image: aliasvault-client
Expand All @@ -23,6 +23,12 @@ services:
context: .
dockerfile: src/AliasVault.Admin/Dockerfile

reverse-proxy:
image: aliasvault-reverse-proxy
build:
context: .
dockerfile: Dockerfile

smtp:
image: aliasvault-smtp
build:
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
postgres-dev:
image: postgres:16-alpine
ports:
- "5433:5432"
volumes:
- ./database/postgres-dev:/var/lib/postgresql/data:rw
- ./src/Databases/AliasServerDb/postgresql.conf:/etc/postgresql/postgresql.conf
environment:
- POSTGRES_DB=aliasvault
- POSTGRES_USER=aliasvault
- POSTGRES_PASSWORD=password
restart: "no"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U aliasvault"]
interval: 5s
timeout: 5s
retries: 5
start_period: 10s
command: ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
62 changes: 48 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
services:
reverse-proxy:
image: ghcr.io/lanedirt/aliasvault-reverse-proxy:latest
ports:
- "${HTTP_PORT:-80}:80"
- "${HTTPS_PORT:-443}:443"
postgres:
image: ghcr.io/lanedirt/aliasvault-postgres:latest
volumes:
- ./certificates/ssl:/etc/nginx/ssl:rw
- ./certificates/letsencrypt:/etc/nginx/ssl-letsencrypt:rw
- ./certificates/letsencrypt/www:/var/www/certbot:rw
depends_on:
- admin
- client
- api
- smtp
restart: always
- ./database/postgres:/var/lib/postgresql/data:rw
env_file:
- .env
restart: always
healthcheck:
test: ["CMD-SHELL", "pg_isready -U aliasvault"]
interval: 5s
timeout: 5s
retries: 5
start_period: 10s

client:
image: ghcr.io/lanedirt/aliasvault-client:latest
Expand All @@ -38,6 +34,11 @@ services:
restart: always
env_file:
- .env
depends_on:
postgres:
condition: service_healthy
environment:
ConnectionStrings__AliasServerDbContext: "Host=postgres;Database=aliasvault;Username=aliasvault;Password=${POSTGRES_PASSWORD}"

admin:
image: ghcr.io/lanedirt/aliasvault-admin:latest
Expand All @@ -50,6 +51,29 @@ services:
restart: always
env_file:
- .env
depends_on:
postgres:
condition: service_healthy
environment:
ConnectionStrings__AliasServerDbContext: "Host=postgres;Database=aliasvault;Username=aliasvault;Password=${POSTGRES_PASSWORD}"

reverse-proxy:
image: ghcr.io/lanedirt/aliasvault-reverse-proxy:latest
ports:
- "${HTTP_PORT:-80}:80"
- "${HTTPS_PORT:-443}:443"
volumes:
- ./certificates/ssl:/etc/nginx/ssl:rw
- ./certificates/letsencrypt:/etc/nginx/ssl-letsencrypt:rw
- ./certificates/letsencrypt/www:/var/www/certbot:rw
depends_on:
- admin
- client
- api
- smtp
restart: always
env_file:
- .env

smtp:
image: ghcr.io/lanedirt/aliasvault-smtp:latest
Expand All @@ -62,6 +86,11 @@ services:
restart: always
env_file:
- .env
depends_on:
postgres:
condition: service_healthy
environment:
ConnectionStrings__AliasServerDbContext: "Host=postgres;Database=aliasvault;Username=aliasvault;Password=${POSTGRES_PASSWORD}"

task-runner:
image: ghcr.io/lanedirt/aliasvault-task-runner:latest
Expand All @@ -71,3 +100,8 @@ services:
restart: always
env_file:
- .env
depends_on:
postgres:
condition: service_healthy
environment:
ConnectionStrings__AliasServerDbContext: "Host=postgres;Database=aliasvault;Username=aliasvault;Password=${POSTGRES_PASSWORD}"
2 changes: 1 addition & 1 deletion docs/installation/advanced/build-from-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nav_order: 1
Instead of using the pre-built Docker images, you can also build the images from source yourself. This allows you to build a specific version of AliasVault and/or to make changes to the source code.

Building from source requires more resources:
- Minimum 2GB RAM (more RAM will speed up build time)
- Minimum 4GB RAM (more RAM will speed up build time)
- At least 1 vCPU
- 40GB+ disk space (for dependencies and build artifacts)
- Docker installed
Expand Down
Loading

0 comments on commit 3263360

Please sign in to comment.