Coder Social home page Coder Social logo

Comments (6)

zachgoll avatar zachgoll commented on July 19, 2024

The SYNTH_API_KEY is not necessarily mandatory, so I think we should keep that out.

The SECRET_KEY_BASE and POSTGRES_PASSWORD are mandatory and are mentioned in the instructions below, but they require you to create a .env file that is consumed by the compose service:

# Create an .env file (make sure to fill in empty variables manually)
cat << EOF > .env
# Use "openssl rand -hex 64" to generate this
SECRET_KEY_BASE=
# Can be any value, set to what you'd like
POSTGRES_PASSWORD=
EOF

I wonder if it might be a bit clearer to write our compose example file this way?

diff --git a/docker-compose.example.yml b/docker-compose.example.yml
index f7f1a3c..a452a0f 100644
--- a/docker-compose.example.yml
+++ b/docker-compose.example.yml
@@ -7,8 +7,6 @@ services:
     ports:
       - 127.0.0.1:3000:3000
     restart: unless-stopped
-    env_file:
-      - .env
     environment:
       SELF_HOSTING_ENABLED: true
       DB_HOST: postgres
@@ -16,6 +14,8 @@ services:
       RAILS_ASSUME_SSL: false
       POSTGRES_USER: postgres
       GOOD_JOB_EXECUTION_MODE: async
+      SECRET_KEY_BASE: ${SECRET_KEY_BASE}
+      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
     depends_on:
       postgres:
         condition: service_healthy

from maybe.

Daniel-RUS avatar Daniel-RUS commented on July 19, 2024

I just honestly didn't understand the point about the .env file . I don't understand yml very well .
I created a .env file and named it stack.env. But for some reason the container didn't start. So I fixed

    env_file:
      - .env

to

    env_file:
      - stack.env

But that didn't help either.
Then I fixed the line:
POSTGRES_PASSWORD: MyPass
And added the lines:

SECRET_KEY_BASE: My_SECRET_KEY_BASE
      SYNTH_API_KEY: My_SYNTH_API_KEY

So, docker just doesn't see the settings file and what to do to make it work I didn't understand(
I specified variables in the file differently:

 SECRET_KEY_BASE = My_SECRET_KEY_BASE
 SECRET_KEY_BASE = 'My_SECRET_KEY_BASE'
 SECRET_KEY_BASE = “My_SECRET_KEY_BASE”

And nothing helped(. It wrote an error that SECRET_KEY_BASE is waiting for a string.

So, either I need to discard the customization file or add:

# Create an .env file (make sure to fill in empty variables manually)
cat << EOF > .env
# 
# Use “openssl rand -hex 64” to generate this 
SECRET_KEY_BASE= 
# Example: SECRET_KEY_BASE = “My_SECRET_KEY_BASE”

# Can be any value, set to what you'd like
POSTGRES_PASSWORD= 
EOF

Translated with DeepL.com (free version)

from maybe.

zachgoll avatar zachgoll commented on July 19, 2024

@Daniel-RUS by default, Docker compose looks for a file with the exact name of .env, so the naming is important here.

It's hard for me to know what has been changed and what has not in your local setup, so would you mind starting from scratch following the exact steps provided in the Docker setup guide?

If anything fails, let me know the step that was either not clear or did not work and I'll get the guide updated.

from maybe.

Daniel-RUS avatar Daniel-RUS commented on July 19, 2024

The command to create the file is not clear. I just manually created the file.
I would write something like “create a maybe.env file with the following contents”. Let them think how to do it themselves. Everyone knows how to do it themselves.
But it is frustrating that the file does not run out of the box. I have never understood how to launch it according to the instructions.
In particular, the problem is in the line:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?}

Even if we specify the file name maybe.env , we still get the following error: error while interpolating services.postgres.environment.POSTGRES_PASSWORD: required variable POSTGRES_PASSWORD is missing a value
Therefore, I suggest changing the line to:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
And change the line with env so that everything works out of the box:

    env_file:
      - maybe.env

Who knows, will change it. And those who don't know how it works will get a positive result. And not like me - I had to read more on this thing.

And in the env file write like this:

# Use “openssl rand -hex 64” to generate this
SECRET_KEY_BASE=opensshex

# Can be any value, set to what you'd like
POSTGRES_PASSWORD=change_me

This is to make it clear how to write with “” or '' or without anything.

However, I did all that and with the env file I get an error:

Attaching to app-1, postgres-1
postgres-1 | Error: Database is uninitialized and superuser password is not specified.
postgres-1 | You must specify POSTGRES_PASSWORD to a non-empty value for the
postgres-1 | superuser. For example, “-e POSTGRES_PASSWORD=password” on “docker run”.

That is, it doesn't see the POSTGRES_PASSWORD field. I don't know why.

Also after startup, the standard login and password didn't work. And this is strange.
And it is not clear how to administer users. If I put the site on the Internet, it turns out that anyone can create their own profile. But it can be solved by password on nginix. It's not a big problem.

The whole problem arose that I do not know all the parameters of yml file. I really walked according to the instructions and did not get a result. Because you need to adapt the yml file. I had to change something in it.

from maybe.

Daniel-RUS avatar Daniel-RUS commented on July 19, 2024

I hope I haven't upset you too much. You have come a long way and I am a novice user. Thank you for developing the application.

from maybe.

Daniel-RUS avatar Daniel-RUS commented on July 19, 2024

I don't know if it is necessary to change it, but they usually write

    ports:
      - 3000:3000

So, as you did is more safely, but maybe someone will have a surprise that the application on the server opens, but there is no PC on the phone or another PC.
I was surprised why the site does not open on my PC, because it works. I spent 10 minutes to understand that everything is in order and the matter is in the configuration. This is because I did not read the yml file before launch, and just see what this thing is.

ports: 
 - 127.0.0.1:3000:3000

`services:

app:
image: ghcr.io/maybe-finance/maybe:latest
volumes:
- ./storage:/rails/storage
ports:
- 3000:3000
restart: unless-stopped
env_file:
- stack.env
environment:
SELF_HOSTING_ENABLED: true
DB_HOST: postgres
RAILS_FORCE_SSL: false
RAILS_ASSUME_SSL: false
POSTGRES_USER: postgres
GOOD_JOB_EXECUTION_MODE: async
depends_on:
postgres:
condition: service_healthy

postgres:
image: postgres:16
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
env_file:
- stack.env
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_DB: ${POSTGRES_DB:-maybe_production}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U $$POSTGRES_USER" ]
interval: 5s
timeout: 5s
retries: 5

volumes:
postgres-data:`

from maybe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.