Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Move custom ports to .env (#441)

Leendert de Borst6286034a9d07
diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml
index 0a2ce10b2..5f075dcf6 100644
--- a/.github/workflows/docker-compose-build.yml
+++ b/.github/workflows/docker-compose-build.yml
@@ -18,16 +18,15 @@ jobs:
steps:
- uses: actions/checkout@v2
+ - name: Create .env file with custom SMTP port as port 25 is not allowed in GitHub Actions
+ run: |
+ echo "SMTP_PORT=2525" > .env
+
- name: Set permissions and run install.sh
run: |
chmod +x install.sh
./install.sh build --verbose
- - name: Set up Docker Compose
- run: |
- sed -i 's/25\:25/2525\:25/g' docker-compose.yml
- docker compose -f docker-compose.yml up -d
-
- name: Test if services are responding
uses: nick-fields/retry@v3
with:
diff --git a/.github/workflows/docker-compose-pull.yml b/.github/workflows/docker-compose-pull.yml
index 2d73c7e70..662f9f753 100644
--- a/.github/workflows/docker-compose-pull.yml
+++ b/.github/workflows/docker-compose-pull.yml
@@ -29,16 +29,17 @@ jobs:
echo "Downloading install script from: $INSTALL_SCRIPT_URL"
curl -f -o install.sh "$INSTALL_SCRIPT_URL"
+ - name: Create .env file with custom SMTP port as port 25 is not allowed in GitHub Actions
+ run: |
+ echo "SMTP_PORT=2525" > .env
+
- 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
+ run: docker compose -f docker-compose.yml up -d
- name: Wait for services to be up
run: |
diff --git a/README.md b/README.md
index dd5d3e12e..3a46e9623 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ The install script will output the URL where the app is available. By default th
- 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: If you want to change the default AliasVault ports you can do so in the `.env` file.
## Detailed documentation
For more detailed information about the installation process and other topics, please see the official documentation website:
diff --git a/docker-compose.yml b/docker-compose.yml
index 6f9d84a14..a2473a718 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -2,8 +2,8 @@ services:
reverse-proxy:
image: ghcr.io/lanedirt/aliasvault-reverse-proxy:latest
ports:
- - "80:80"
- - "443:443"
+ - "${HTTP_PORT:-80}:80"
+ - "${HTTPS_PORT:-443}:443"
volumes:
- ./certificates/ssl:/etc/nginx/ssl:rw
- ./certificates/letsencrypt:/etc/nginx/ssl-letsencrypt:rw
@@ -54,8 +54,8 @@ services:
smtp:
image: ghcr.io/lanedirt/aliasvault-smtp:latest
ports:
- - "25:25"
- - "587:587"
+ - "${SMTP_PORT:-25}:25"
+ - "${SMTP_TLS_PORT:-587}:587"
volumes:
- ./database:/database:rw
- ./logs:/logs:rw
diff --git a/docs/installation/install.md b/docs/installation/install.md
index fb3c5a9bf..30388a350 100644
--- a/docs/installation/install.md
+++ b/docs/installation/install.md
@@ -37,7 +37,7 @@ chmod +x install.sh
```bash
./install.sh install
```
-> **Note**: AliasVault binds to ports 80 and 443 by default. If you want to change the default AliasVault ports you can do so in the `docker-compose.yml` file for the `reverse-proxy` (nginx) container. Afterwards re-run the `./install.sh install` command to restart the containers with the new port settings.
+> **Note**: AliasVault binds to ports 80 and 443 by default. If you want to change the default AliasVault ports you can do so in the `.env` file. Afterwards re-run the `./install.sh install` command to restart the containers with the new port settings.
3. After the script completes, you can access AliasVault at:
- Client: `https://localhost`
diff --git a/install.sh b/install.sh
index 14e8861f7..f03e1d6d3 100755
--- a/install.sh
+++ b/install.sh
@@ -420,6 +420,37 @@ generate_admin_password() {
fi
}
+# Function to set default ports
+set_default_ports() {
+ printf "${CYAN}> Checking default ports...${NC}\n"
+
+ # Web ports
+ if ! grep -q "^HTTP_PORT=" "$ENV_FILE" || [ -z "$(grep "^HTTP_PORT=" "$ENV_FILE" | cut -d '=' -f2)" ]; then
+ update_env_var "HTTP_PORT" "80"
+ else
+ printf " ${GREEN}> HTTP_PORT already exists.${NC}\n"
+ fi
+
+ if ! grep -q "^HTTPS_PORT=" "$ENV_FILE" || [ -z "$(grep "^HTTPS_PORT=" "$ENV_FILE" | cut -d '=' -f2)" ]; then
+ update_env_var "HTTPS_PORT" "443"
+ else
+ printf " ${GREEN}> HTTPS_PORT already exists.${NC}\n"
+ fi
+
+ # SMTP ports
+ if ! grep -q "^SMTP_PORT=" "$ENV_FILE" || [ -z "$(grep "^SMTP_PORT=" "$ENV_FILE" | cut -d '=' -f2)" ]; then
+ update_env_var "SMTP_PORT" "25"
+ else
+ printf " ${GREEN}> SMTP_PORT already exists.${NC}\n"
+ fi
+
+ if ! grep -q "^SMTP_TLS_PORT=" "$ENV_FILE" || [ -z "$(grep "^SMTP_TLS_PORT=" "$ENV_FILE" | cut -d '=' -f2)" ]; then
+ update_env_var "SMTP_TLS_PORT" "587"
+ else
+ printf " ${GREEN}> SMTP_TLS_PORT already exists.${NC}\n"
+ fi
+}
+
# Helper function to update environment variables
update_env_var() {
local key=$1
@@ -433,6 +464,7 @@ update_env_var() {
printf " ${GREEN}> $key has been set in $ENV_FILE.${NC}\n"
}
+
# Helper function to delete environment variables
delete_env_var() {
local key=$1
@@ -574,6 +606,7 @@ handle_build() {
set_private_email_domains || { printf "${RED}> Failed to set email domains${NC}\n"; exit 1; }
set_smtp_tls_enabled || { printf "${RED}> Failed to set SMTP TLS${NC}\n"; exit 1; }
set_support_email || { printf "${RED}> Failed to set support email${NC}\n"; exit 1; }
+ set_default_ports || { printf "${RED}> Failed to set default ports${NC}\n"; exit 1; }
# Only generate admin password if not already set
if ! grep -q "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" || [ -z "$(grep "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" | cut -d '=' -f2)" ]; then
@@ -1254,6 +1287,7 @@ handle_install_version() {
set_private_email_domains || { printf "${RED}> Failed to set email domains${NC}\n"; exit 1; }
set_smtp_tls_enabled || { printf "${RED}> Failed to set SMTP TLS${NC}\n"; exit 1; }
set_support_email || { printf "${RED}> Failed to set support email${NC}\n"; exit 1; }
+ set_default_ports || { printf "${RED}> Failed to set default ports${NC}\n"; exit 1; }
# Only generate admin password if not already set
if ! grep -q "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" || [ -z "$(grep "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" | cut -d '=' -f2)" ]; then