Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish docker images on release #379

Merged
merged 18 commits into from
Nov 18, 2024
Merged
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
11 changes: 6 additions & 5 deletions .github/workflows/docker-compose-build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This workflow will test if building the Docker Compose containers from scratch works.
name: Docker Compose Build

on:
Expand All @@ -20,7 +21,7 @@ jobs:
- name: Set permissions and run install.sh
run: |
chmod +x install.sh
./install.sh
./install.sh build --verbose

- name: Set up Docker Compose
run: |
Expand Down Expand Up @@ -87,11 +88,11 @@ jobs:
echo "SmtpService responded on port 2525"
fi

- name: Test install.sh --reset-password output
- name: Test install.sh reset-password output
run: |
output=$(./install.sh --reset-password)
if ! echo "$output" | grep -E '^Password: [a-zA-Z0-9]{8,}$'; then
echo "Password reset output format is incorrect. Expected format: 'Password: <at least 8 chars>'"
output=$(./install.sh reset-password)
if ! echo "$output" | grep -E '.*New admin password: [A-Za-z0-9]{8,}.*'; then
echo "Password reset output format is incorrect. Expected format: 'New admin password: <at least 8 chars>'"
echo "Actual output: $output"
exit 1
else
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/docker-compose-pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# This workflow will test if pulling the latest Docker Compose containers from the registry works.
name: Docker Compose Pull

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test-docker:
runs-on: ubuntu-latest

services:
docker:
image: docker:26.0.0
options: --privileged

steps:
- uses: actions/checkout@v2
- name: Set permissions and run install.sh
run: |
chmod +x install.sh
./install.sh install --verbose

- name: Set up Docker Compose
run: |
# Change the exposed host port of the SmtpService from 25 to 2525 because port 25 is not allowed in GitHub Actions
sed -i 's/25\:25/2525\:25/g' docker-compose.yml
docker compose -f docker-compose.yml up -d

- name: Wait for services to be up
run: |
# Wait for a few seconds
sleep 10
- name: Test if localhost:443 (WASM app) responds
uses: nick-fields/retry@v3
with:
timeout_minutes: 2
max_attempts: 3
command: |
http_code=$(curl -k -s -o /dev/null -w "%{http_code}" https://localhost:443)
if [ "$http_code" -ne 200 ]; then
echo "Service did not respond with 200 OK. Check if client app and/or nginx is configured correctly."
exit 1
else
echo "Service responded with 200 OK"
fi

- name: Test if localhost:443/api (WebApi) responds
uses: nick-fields/retry@v3
with:
timeout_minutes: 2
max_attempts: 3
command: |
http_code=$(curl -k -s -o /dev/null -w "%{http_code}" https://localhost:443/api)
if [ "$http_code" -ne 200 ]; then
echo "Service did not respond with expected 200 OK. Check if WebApi and/or nginx is configured correctly."
exit 1
else
echo "Service responded with $http_code"
fi

- name: Test if localhost:443/admin (Admin) responds
uses: nick-fields/retry@v3
with:
timeout_minutes: 2
max_attempts: 3
command: |
http_code=$(curl -k -s -o /dev/null -w "%{http_code}" https://localhost:443/admin/user/login)
if [ "$http_code" -ne 200 ]; then
echo "Service did not respond with expected 200 OK. Check if admin app and/or nginx is configured correctly."
exit 1
else
echo "Service responded with $http_code"
fi

- name: Test if localhost:2525 (SmtpService) responds
uses: nick-fields/retry@v3
with:
timeout_minutes: 2
max_attempts: 3
command: |
if ! nc -zv localhost 2525 2>&1 | grep -q 'succeeded'; then
echo "SmtpService did not respond on port 2525. Check if the SmtpService service is running."
exit 1
else
echo "SmtpService responded on port 2525"
fi

- name: Test install.sh reset-password output
run: |
output=$(./install.sh reset-password)
if ! echo "$output" | grep -E '.*New admin password: [A-Za-z0-9]{8,}.*'; then
echo "Password reset output format is incorrect. Expected format: 'New admin password: <at least 8 base64 chars>'"
echo "Actual output: $output"
exit 1
else
echo "Password reset output format is correct"
fi
1 change: 1 addition & 0 deletions .github/workflows/dotnet-e2e-admin-tests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This workflow will test if running the E2E Admin tests via Playwright CLI works.
name: .NET E2E Admin Tests (Playwright)

on:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/dotnet-e2e-client-tests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This workflow will test if running the E2E Client tests via Playwright CLI works.
name: .NET E2E Client Tests (Playwright with Sharding)

on:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/dotnet-e2e-misc-tests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This workflow will test if running the E2E Misc tests via Playwright CLI works.
name: .NET E2E Misc Tests (Playwright)

on:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/dotnet-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

# This workflow will test if running the integration tests works.
name: .NET Integration Tests

on:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/dotnet-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

# This workflow will test if running the unit tests works.
name: .NET Unit Tests

on:
Expand Down
25 changes: 19 additions & 6 deletions .github/workflows/publish-docker-images.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This workflow will publish new Docker images to the GitHub Container Registry when a new release is published.
name: Publish Docker Images

on:
Expand All @@ -20,6 +21,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Convert repository name to lowercase
run: |
echo "REPO_LOWER=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
Expand All @@ -31,44 +36,52 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}

- name: Build and push API image
uses: docker/build-push-action@v5
with:
context: .
file: src/AliasVault.Api/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}-api:latest,${{ env.REGISTRY }}/${{ github.repository }}-api:${{ github.ref_name }}
tags: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-api:latest,${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-api:${{ github.ref_name }}

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

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

- name: Build and push SMTP image
uses: docker/build-push-action@v5
with:
context: .
file: src/Services/AliasVault.SmtpService/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}-smtp:latest,${{ env.REGISTRY }}/${{ github.repository }}-smtp:${{ github.ref_name }}
tags: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-smtp:latest,${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-smtp:${{ 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 }}/${{ github.repository }}-reverse-proxy:latest,${{ env.REGISTRY }}/${{ github.repository }}-reverse-proxy:${{ github.ref_name }}
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:
context: .
file: src/Utilities/AliasVault.InstallCli/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-installcli:latest,${{ env.REGISTRY }}/${{ env.REPO_LOWER }}-installcli:${{ github.ref_name }}
1 change: 1 addition & 0 deletions .github/workflows/sonarcloud-code-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This workflow will perform a SonarCloud code analysis on every push to the main branch or when a pull request is opened, synchronized, or reopened.
name: SonarCloud code analysis
on:
push:
Expand Down
70 changes: 47 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Open-source password and alias manager
</h3>

[<img src="https://img.shields.io/github/v/release/lanedirt/AliasVault?include_prereleases&logo=github">](https://github.com/lanedirt/OGameX/releases)
[<img src="https://img.shields.io/github/v/release/lanedirt/AliasVault?include_prereleases&logo=github">](https://github.com/lanedirt/AliasVault/releases)
[<img src="https://img.shields.io/github/actions/workflow/status/lanedirt/AliasVault/docker-compose-build.yml?label=docker-compose%20build">](https://github.com/lanedirt/AliasVault/actions/workflows/docker-compose-build.yml)
[<img src="https://img.shields.io/github/actions/workflow/status/lanedirt/AliasVault/dotnet-unit-tests.yml?label=unit tests">](https://github.com/lanedirt/AliasVault/actions/workflows/dotnet-build-run-tests.yml)
[<img src="https://img.shields.io/github/actions/workflow/status/lanedirt/AliasVault/dotnet-integration-tests.yml?label=integration tests">](https://github.com/lanedirt/AliasVault/actions/workflows/dotnet-build-run-tests.yml)
Expand All @@ -35,42 +35,66 @@ A live demo of the app is available at the official website at [app.aliasvault.n
<img width="700" alt="Screenshot of AliasVault" src="docs/img/screenshot.png">

## Installation
To install AliasVault on your local machine, follow the steps below. Note: the install process is tested on MacOS and Linux. It should work on Windows too, but you might need to adjust some commands.

### Requirements:
- Access to a terminal
- Docker
- Git
Choose one of the following installation methods:

### 1. Clone and run install script
AliasVault comes with a install script that prepares the .env file, builds the Docker image, and starts the AliasVault containers.
### Option 1: Quick Install (Pre-built Images)

This method uses pre-built Docker images and works on minimal hardware specifications:
- Linux (Ubuntu or RHEL based distros recommended)
- 512MB RAM
- 1 vCPU
- At least 16GB disk space (more users and emails will require more space)
- Docker installed
- No Git required

```bash
# Clone this Git repository to "AliasVault" directory
$ git clone https://github.com/lanedirt/AliasVault.git
# Download install script
curl -o install.sh https://raw.githubusercontent.com/lanedirt/AliasVault/main/install.sh

# Make install script executable and run it. This will create the .env file, pull the Docker images, and start the AliasVault containers.
chmod +x install.sh
./install.sh install
```

### Option 2: Build from Source

# Go to the project directory
$ cd AliasVault
Building from source requires more resources:
- Minimum 2GB RAM (more RAM will speed up build time)
- At least 1 vCPU
- 40GB+ disk space (for dependencies and build artifacts)
- Docker installed
- Git installed

# Make install script executable and run it.
$ chmod +x install.sh && ./install.sh
```bash
# Clone the repository
git clone https://github.com/lanedirt/AliasVault.git
cd AliasVault

# Make build script executable and run it. This will create the .env file, build the Docker images from source, and start the AliasVault containers.
chmod +x install.sh
./install.sh build
```

Note: if you do not wish to run the script, you can set up the environment variables and build the Docker image and containers manually instead. See the [manual setup instructions](docs/install/1-manually-setup-docker.md) for more information.
Note: If you do not wish to run the script, you can set up the environment variables and build the Docker image and containers manually instead. See the [manual setup instructions](docs/install/1-manually-setup-docker.md) for more information.

### Post-Installation

### 2. Ready to use
The install script executed in step #1 will output the URL where the app is available. By default this is https://localhost for the client and https://localhost/admin for the admin portal.
The install script will output the URL where the app is available. By default this is:
- Client: https://localhost
- Admin portal: https://localhost/admin

> Note: If you want to change the default AliasVault ports you can do so in the `docker-compose.yml` file for the `nginx` (reverse-proxy) container.

#### Note for first time build:
- When running the init script for the first time, it may take a few minutes for Docker to download all dependencies. Subsequent builds will be faster.
#### First Time Setup Notes:
- When building from source for the first time, it may take several minutes for Docker to download and compile all dependencies. Subsequent builds will be faster.
- A SQLite database file will be created in `./database/AliasServerDb.sqlite`. This file will store all (encrypted) password vaults. It should be kept secure and not shared.

#### Other useful commands:
- To reset the admin password, run the install.sh script with the `--reset-admin-password` flag.
- To uninstall AliasVault, make the uninstall script executable with `chmod +x uninstall.sh` first, then run the script: `./uninstall.sh`.
This will remove all containers, images, and volumes related to AliasVault. It will keep all files and configuration intact however, so you can easily reinstall AliasVault later.
#### Useful Commands:
- To reset the admin password: `./install.sh reset-password`
- To uninstall AliasVault: `./install.sh uninstall`
This will remove all containers, images, and volumes related to AliasVault while keeping configuration files intact for future reinstallation.
- If something goes wrong you can run the install script in verbose mode to get more information: `./install.sh [command] --verbose`

## Security & Architecture
AliasVault takes security seriously and implements various measures to protect your data:
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
reverse-proxy:
image: aliasvault-reverse-proxy
build:
context: .
dockerfile: Dockerfile

client:
image: aliasvault-client
build:
context: .
dockerfile: src/AliasVault.Client/Dockerfile

api:
image: aliasvault-api
build:
context: .
dockerfile: src/AliasVault.Api/Dockerfile

admin:
image: aliasvault-admin
build:
context: .
dockerfile: src/AliasVault.Admin/Dockerfile

smtp:
image: aliasvault-smtp
build:
context: .
dockerfile: src/Services/AliasVault.SmtpService/Dockerfile
Loading
Loading