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

Secret key base generation ✨ #13

Merged
merged 1 commit into from
Jun 29, 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ It is designed to be easy to install and use.
## Debian/Ubuntu one command installation

```bash
curl -fsSL https://gitd.fr/-/snippets/1/raw/main/ia.sh | RAILS_MASTER_KEY=<KEY> sh
curl -fsSL https://gitd.fr/-/snippets/1/raw/main/ia.sh | sh
```

You should see the following output:
Expand Down Expand Up @@ -45,7 +45,7 @@ On the Debian/Ubuntu VM:
Replace `<HOST_IP>` with the IP address of the host machine and `<KEY>` with the Rails master key and run the following command:

```bash
curl -fsSL https://gitd.fr/-/snippets/1/raw/main/ia.sh | OLLAMA_URL=<HOST_IP>:11434 RAILS_MASTER_KEY=<KEY> sh
curl -fsSL https://gitd.fr/-/snippets/1/raw/main/ia.sh | OLLAMA_URL=<HOST_IP>:11434 sh
```

You should see the following output:
Expand Down
1 change: 0 additions & 1 deletion config/credentials.yml.enc

This file was deleted.

12 changes: 8 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ services:
ports:
- "3000:3000"
environment:
- RAILS_MASTER_KEY=$RAILS_MASTER_KEY
- DATABASE_URL=$DATABASE_URL
- OLLAMA_URL=$OLLAMA_URL
- OLLAMA_MODEL=$OLLAMA_MODEL
- OLLAMA_CHAT_COMPLETION_MODEL=$OLLAMA_CHAT_COMPLETION_MODEL
- OLLAMA_COMPLETION_MODEL=$OLLAMA_COMPLETION_MODEL
- OLLAMA_EMBEDDINGS_MODEL=$OLLAMA_EMBEDDINGS_MODEL
- SECRET_KEY_BASE=$SECRET_KEY_BASE
depends_on:
postgres-db:
condition: service_healthy
Expand All @@ -35,10 +37,12 @@ services:
build: .
command: bundle exec rake solid_queue:start
environment:
- RAILS_MASTER_KEY=$RAILS_MASTER_KEY
- DATABASE_URL=$DATABASE_URL
- OLLAMA_URL=$OLLAMA_URL
- OLLAMA_MODEL=$OLLAMA_MODEL
- OLLAMA_CHAT_COMPLETION_MODEL=$OLLAMA_CHAT_COMPLETION_MODEL
- OLLAMA_COMPLETION_MODEL=$OLLAMA_COMPLETION_MODEL
- OLLAMA_EMBEDDINGS_MODEL=$OLLAMA_EMBEDDINGS_MODEL
- SECRET_KEY_BASE=$SECRET_KEY_BASE
depends_on:
postgres-db:
condition: service_healthy
2 changes: 1 addition & 1 deletion script/production/setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source ./script/concerns/loader

start_loader "Setting up environment"
OLLAMA_CHAT_COMPLETION_MODEL=$OLLAMA_CHAT_COMPLETION_MODEL OLLAMA_COMPLETION_MODEL=$OLLAMA_COMPLETION_MODEL OLLAMA_URL=$OLLAMA_URL RAILS_MASTER_KEY=$RAILS_MASTER_KEY ./script/production/setup-env &>> ./log/production.log
OLLAMA_CHAT_COMPLETION_MODEL=$OLLAMA_CHAT_COMPLETION_MODEL OLLAMA_COMPLETION_MODEL=$OLLAMA_COMPLETION_MODEL OLLAMA_URL=$OLLAMA_URL ./script/production/setup-env &>> ./log/production.log
stop_loader

start_loader "Setting up Docker"
Expand Down
10 changes: 2 additions & 8 deletions script/production/setup-env
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ fi

echo "Generating .env file"

if [ -n "$RAILS_MASTER_KEY" ]; then
echo "Using RAILS_MASTER_KEY from environment"
else
echo "RAILS_MASTER_KEY is not set, exiting"
exit 1
fi

if [ -n "$OLLAMA_URL" ]; then
echo "Using OLLAMA_URL from environment"
else
Expand Down Expand Up @@ -48,6 +41,7 @@ POSTGRES_DB=nosia_production
POSTGRES_USER=nosia
POSTGRES_PASSWORD=$(openssl rand -base64 32)
DATABASE_URL=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB
SECRET_KEY_BASE=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 63 ; echo '')

echo "DATABASE_URL=$DATABASE_URL" > .env
echo "OLLAMA_URL=$OLLAMA_URL" >> .env
Expand All @@ -59,6 +53,6 @@ echo "POSTGRES_PORT=$POSTGRES_PORT" >> .env
echo "POSTGRES_DB=$POSTGRES_DB" >> .env
echo "POSTGRES_USER=$POSTGRES_USER" >> .env
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> .env
echo "RAILS_MASTER_KEY=$RAILS_MASTER_KEY" >> .env
echo "SECRET_KEY_BASE=$SECRET_KEY_BASE" >> .env

echo ".env file generated"