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

already have nginx installed on server.... #4

Open
ralyodio opened this issue Aug 6, 2019 · 22 comments
Open

already have nginx installed on server.... #4

ralyodio opened this issue Aug 6, 2019 · 22 comments

Comments

@ralyodio
Copy link

ralyodio commented Aug 6, 2019

How can I just expose the app on port 3000 so I can use my existing nginx proxy to server the application? Specifically what changes do I need to make to docker?

@jamesbrink
Copy link
Member

I don't think you need to make any changes to the Dockerfile as it already exposes port 3000. If you are running nginx on your local host you can probably just alter the docker-compose to something like this, removing the nginx proxy and the depends_on statement under the app for nginx proxy.

version: '2.1'

services:
  database:
    image: mariadb
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=lobsters
    healthcheck:
      test: "/usr/bin/mysql --user=root --password=password --execute \"SHOW DATABASES;\""
      timeout: 5s
      retries: 20
    volumes:
      - 'lobsters_database:/var/lib/mysql'
  app:
    build:
      context: .
      args:
        developer_build: "false"
    environment:
      - MARIADB_HOST=database
      - MARIADB_PORT=3306
      - MARIADB_PASSWORD=password
      - MARIADB_USER=root
      - LOBSTER_DATABASE=lobsters
      - LOBSTER_SITE_NAME="Example News"
      - RAILS_ENV=development
      - LOBSTER_HOSTNAME=localhost
      - VIRTUAL_HOST=localhost
      - RAILS_MAX_THREADS=5
    ports:
      - "3000:3000"
    depends_on:
      database:
        condition: service_healthy

volumes:
  lobsters_database:
    driver: local

@jamesbrink
Copy link
Member

@chovy let me know if the above works for you, if not please give some additional details on your environment.

@ralyodio
Copy link
Author

ralyodio commented Aug 6, 2019

I will try, another problem I'm having is I want to use a Mailgun SMTP server for sending email.

@jamesbrink
Copy link
Member

jamesbrink commented Aug 6, 2019

I am not sure how to setup mailgun, but I just took some time to update this repo, so you might want to pull the new changes. I setup the build in circle-ci and updated the git submodule of lobsters to the most current git commit.

I did this as i noticed the old build was no longer working

@jamesbrink
Copy link
Member

the docker-compose now uses the pre-built image from https://hub.docker.com/r/utensils/lobsters
but it can be built locally use make. I will update the Readme tomorrow with the information.

@jamesbrink
Copy link
Member

jamesbrink commented Aug 6, 2019

With these new updates, you could pull try the following docker-compose

version: '2.1'

services:
  database:
    image: mariadb
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=lobsters
    healthcheck:
      test: "/usr/bin/mysql --user=root --password=password --execute \"SHOW DATABASES;\""
      timeout: 5s
      retries: 20
    volumes:
      - 'lobsters_database:/var/lib/mysql'
  app:
    image: utensils/lobsters:latest
    build:
      context: .
      args:
        DEVELOPER_BUILD: "false"
    environment:
      - MARIADB_HOST=database
      - MARIADB_PORT=3306
      - MARIADB_PASSWORD=password
      - MARIADB_USER=root
      - LOBSTER_DATABASE=lobsters
      - LOBSTER_SITE_NAME="Example News"
      - RAILS_ENV=development
      - LOBSTER_HOSTNAME=localhost
      - VIRTUAL_HOST=localhost
      - RAILS_MAX_THREADS=5
    ports:
      - "3000:3000"
    depends_on:
      database:
        condition: service_healthy

volumes:
  lobsters_database:
    driver: local

@ralyodio
Copy link
Author

ralyodio commented Aug 6, 2019

I need to configure the SMTP server somehow.

@jamesbrink
Copy link
Member

@chovy there are ENV variables setup for using SMTP

From the Dockerfile

    SMTP_HOST="127.0.0.1" \
    SMTP_PORT="25" \
    SMTP_STARTTLS_AUTO="true" \
    SMTP_USERNAME="lobsters" \
    SMTP_PASSWORD="lobsters"

So given the previous docker-compose example you could simply add those variables.

version: '2.1'

services:
  database:
    image: mariadb
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=lobsters
    healthcheck:
      test: "/usr/bin/mysql --user=root --password=password --execute \"SHOW DATABASES;\""
      timeout: 5s
      retries: 20
    volumes:
      - 'lobsters_database:/var/lib/mysql'
  app:
    image: utensils/lobsters:latest
    build:
      context: .
      args:
        DEVELOPER_BUILD: "false"
    environment:
      - MARIADB_HOST=database
      - MARIADB_PORT=3306
      - MARIADB_PASSWORD=password
      - MARIADB_USER=root
      - LOBSTER_DATABASE=lobsters
      - LOBSTER_SITE_NAME="Example News"
      - RAILS_ENV=development
      - LOBSTER_HOSTNAME=localhost
      - VIRTUAL_HOST=localhost
      - RAILS_MAX_THREADS=5
      - SMTP_HOST="your.smtp.host.com"
      - SMTP_PORT="25"
      - SMTP_STARTTLS_AUTO="true"
      - SMTP_USERNAME="yoursmtpusername"
      - SMTP_PASSWORD="yoursmtppass"
    ports:
      - "3000:3000"
    depends_on:
      database:
        condition: service_healthy

volumes:
  lobsters_database:
    driver: local

@ralyodio
Copy link
Author

ralyodio commented Aug 6, 2019

ahh ok. Trying now. Thanks.

@ralyodio
Copy link
Author

ralyodio commented Aug 6, 2019

I tried connection to localhost:3000 but it isn't up.

@ralyodio
Copy link
Author

ralyodio commented Aug 6, 2019

So I got it working, but mail still won't send. It says it can't find the config/initailizers/mail script

app_1_8dd569ff291a | ruby: No such file or directory -- script/mail_new_activity (LoadError)

@jamesbrink
Copy link
Member

Ah I see this, i think the renamed the file upstream. I will fix this now

@jamesbrink
Copy link
Member

if you pull the newest docker image docker pull utensils/lobsters:latest then start it up again it should be fixed. I did notice it throws an Nil Class error, but I think this stops erroring once their is content on the site. That mailer script runs every 5 minutes. I don't have an SMTP service setup to test and verify, but I was able to verify they did re-name the file so I just updated the entrypoint script.

@ralyodio
Copy link
Author

ralyodio commented Aug 7, 2019

Just an fyi, you can't use quotes in docker-compose for environemnt variables. They show up in the values.

Also I read that docker-compose will look for a .env file in the root so that would be a better way of adding environment variables.

I still get this error:

app_1_8dd569ff291a | ruby: No such file or directory -- script/mail_new_activity (LoadError)

@ralyodio
Copy link
Author

ralyodio commented Aug 7, 2019

app_1_8dd569ff291a | script/mail_new_activity.rb:146:in

': undefined method id' for nil:NilClass (NoMethodError)

@jamesbrink
Copy link
Member

@chovy this is the NilClass error i mentioned earlier, i think you can safely ignore it. once you have stories and comments it stops erroring. I think they really just need to put in a check for nil in that script. I doub't they ever see it because it only happens on fresh empty site. I added a story locally, changed a few things and it stopped coming back with that error. like i said it runs every 5 minutes so it can be safely ignored.

@jamesbrink
Copy link
Member

Also I read that docker-compose will look for a .env file in the root so that would be a better way of adding environment variables.

I will look into adding this, that is probably a better idea. This project could use some work, I no longer run this anymore, but I do try to maintain the repo for others. I did run it for a bit with no issues, now the biggest issue is just keeping it updated :)

@ralyodio
Copy link
Author

ralyodio commented Aug 7, 2019

did you have to make a lot of customizations to lobsters code?

@ralyodio
Copy link
Author

ralyodio commented Aug 7, 2019

I got mail working! I had to use smtp.mailgun.org port 587. Shit works now! thank you!

@ralyodio ralyodio closed this as completed Aug 7, 2019
@ralyodio
Copy link
Author

Something broke. I'm now getting this error.

sendmail: can't connect to remote host (127.0.0.1): Connection refused -- seems to be ignoring the docker-compose env. variables

@ralyodio ralyodio reopened this Aug 12, 2019
@XuebinMa
Copy link

XuebinMa commented Mar 11, 2020

@chovy I got my smtp server worked .

  1. Edit the file: ~/docker-lobsters/Dockfile and change the variables like "SMPT_****".
  2. Edit the file: ~/docker-lobsters/lobsters/app/mailers/invitation_mailer.rb and change the "nobody" to your user name of your email address .

@anon238
Copy link

anon238 commented Mar 7, 2021

Something broke. I'm now getting this error.

sendmail: can't connect to remote host (127.0.0.1): Connection refused -- seems to be ignoring the docker-compose env. variables

You cannot use localhost!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants