Skip to content
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
24 changes: 23 additions & 1 deletion cli/app/commands/install/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,20 @@ def _setup_clone_and_config(self):
def _create_env_files(self):
api_env_file = self._get_config("api_env_file_path")
view_env_file = self._get_config("view_env_file_path")

full_source_path = self._get_config("full_source_path")
combined_env_file = os.path.join(full_source_path, ".env")
FileManager.create_directory(FileManager.get_directory_path(api_env_file), logger=self.logger)
FileManager.create_directory(FileManager.get_directory_path(view_env_file), logger=self.logger)
FileManager.create_directory(FileManager.get_directory_path(combined_env_file), logger=self.logger)

services = [
("api", "services.api.env", api_env_file),
("view", "services.view.env", view_env_file),
]
env_manager = BaseEnvironmentManager(self.logger)

# individual service env files
for i, (service_name, service_key, env_file) in enumerate(services):
env_values = _config.get_service_env_values(service_key)
updated_env_values = self._update_environment_variables(env_values)
Expand All @@ -312,6 +318,22 @@ def _create_env_files(self):
raise Exception(f"{env_file_permissions_failed} {service_name}: {file_perm_error}")
self.logger.debug(created_env_file.format(service_name=service_name, env_file=env_file))

# combined env file with both API and view variables
api_env_values = _config.get_service_env_values("services.api.env")
view_env_values = _config.get_service_env_values("services.view.env")

combined_env_values = {}
combined_env_values.update(self._update_environment_variables(api_env_values))
combined_env_values.update(self._update_environment_variables(view_env_values))
success, error = env_manager.write_env_file(combined_env_file, combined_env_values)

if not success:
raise Exception(f"{env_file_creation_failed} combined: {error}")
file_perm_success, file_perm_error = FileManager.set_permissions(combined_env_file, 0o644)
if not file_perm_success:
raise Exception(f"{env_file_permissions_failed} combined: {file_perm_error}")
self.logger.debug(created_env_file.format(service_name="combined", env_file=combined_env_file))

def _setup_proxy_config(self):
full_source_path = self._get_config("full_source_path")
caddy_json_template = os.path.join(full_source_path, "helpers", "caddy.json")
Expand Down Expand Up @@ -439,7 +461,7 @@ def _update_environment_variables(self, env_values: dict) -> dict:
"SUPERTOKENS_API_KEY": "NixopusSuperTokensAPIKey",
"SUPERTOKENS_API_DOMAIN": f"{protocol}://{api_host}/api",
"SUPERTOKENS_WEBSITE_DOMAIN": f"{protocol}://{view_host}",
"SUPERTOKENS_CONNECTION_URI": f"{protocol}://{api_host}:{supertokens_api_port}/api",
"SUPERTOKENS_CONNECTION_URI": f"{protocol}://{api_host}:{supertokens_api_port}",
}

for key, value in key_map.items():
Expand Down
2 changes: 1 addition & 1 deletion cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nixopus"
version = "0.1.7"
version = "0.1.8"
description = "A CLI for Nixopus"
authors = ["Nixopus <raghavyuva@gmail.com>"]
readme = "README.md"
Expand Down
8 changes: 6 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
- ${NIXOPUS_HOME:-/etc/nixopus}/source/api/.env
environment:
- HOST_NAME=nixopus-db

volumes:
- ./logs:/app/logs
- ${NIXOPUS_HOME:-/etc/nixopus}:/etc/nixopus
Expand All @@ -31,6 +32,7 @@ services:
- POSTGRES_PASSWORD=${PASSWORD}
- POSTGRES_DB=${DB_NAME}
- POSTGRES_HOST_AUTH_METHOD=trust

ports:
- "${DB_PORT:-5432}:5432"
volumes:
Expand All @@ -49,6 +51,8 @@ services:
build:
args:
- NEXT_PUBLIC_PORT=${NEXT_PUBLIC_PORT}
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
- NEXT_PUBLIC_WEBSITE_DOMAIN=${NEXT_PUBLIC_WEBSITE_DOMAIN}
ports:
- "${NEXT_PUBLIC_PORT:-7443}:${NEXT_PUBLIC_PORT:-7443}"
restart: unless-stopped
Expand Down Expand Up @@ -95,11 +99,11 @@ services:
"--config",
"/etc/caddy/Caddyfile",
"--adapter",
"caddyfile"
"caddyfile",
]
networks:
- nixopus-network

supertokens:
image: registry.supertokens.io/supertokens/supertokens-postgresql:latest
depends_on:
Expand Down
4 changes: 4 additions & 0 deletions view/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ COPY --from=deps /app/node_modules ./node_modules
COPY . .

ARG NEXT_PUBLIC_PORT=7443
ARG NEXT_PUBLIC_API_URL=http://localhost:8443/api
ARG NEXT_PUBLIC_WEBSITE_DOMAIN=http://localhost:7443
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=$NEXT_PUBLIC_PORT
ENV NEXT_PUBLIC_PORT=$NEXT_PUBLIC_PORT
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_WEBSITE_DOMAIN=$NEXT_PUBLIC_WEBSITE_DOMAIN

RUN yarn build && \
rm -rf node_modules/.cache
Expand Down
Loading