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

Docker Compose Support #363

Closed
treed593 opened this issue Nov 5, 2017 · 15 comments
Closed

Docker Compose Support #363

treed593 opened this issue Nov 5, 2017 · 15 comments

Comments

@treed593
Copy link

treed593 commented Nov 5, 2017

Has anyone started work on a docker-compose.yml file for alf.io?

@cbellone
Copy link
Member

Hi @treed593 ,
no, we don't have any docker-compose.yml yet. Are you willing to work on that?

Just FYI, we're considering the possibility to drop the support for MySql / MariaDB in the next releases. So it would be better if the docker-compose could focus on PostgreSQL.

Thanks!
Celestino

@asymmetric
Copy link
Contributor

asymmetric commented Oct 3, 2018

I'm trying to run alf.io with Docker Compose, but I'm getting an error.

Here's the docker-compose.yml:

version: '3'
services:
  alfio:
    image: "alfio/alf.io:1.16"
    ports:
      - "8080:8080"
    links:
      - "db:postgres"
  db:
    image: postgres
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USERNAME: postgres
      POSTGRES_PASSWORD: foobar
    volumes:
      - "data-volume:/var/lib/postgresql/data"
volumes:
  data-volume:

And here's the output:

alfio_1  | >> powered by Spring Boot
alfio_1  |
alfio_1  | 19:26:51.048 [main] INFO  alfio.config.SpringBootLauncher - Starting SpringBootLauncher on 7db8176d3eae with PID 8 (/home/alfio/alfio-boot.war started by alfio in /home/alfio)
alfio_1  | 19:26:51.055 [main] INFO  alfio.config.SpringBootLauncher - The following profiles are active: spring-boot,stdout
alfio_1  | 19:26:52.996 [main] WARN  org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling
 refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'queryRepositoryScanner' defined in alfio.config.RepositoryConfiguration: Uns
atisfied dependency expressed through method 'queryRepositoryScanner' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean wi
th name 'queryFactory' defined in alfio.config.DataSourceConfiguration: Unsatisfied dependency expressed through method 'queryFactory' parameter 1; nested exception is org.springframework.bea
ns.factory.BeanCreationException: Error creating bean with name 'getCloudProvider' defined in alfio.config.DataSourceConfiguration: Bean instantiation via factory method failed; nested except
ion is org.springframework.beans.BeanInstantiationException: Failed to instantiate [alfio.config.support.PlatformProvider]: Factory method 'getCloudProvider' threw exception; nested exception
 is java.lang.IllegalStateException: Required key 'datasource.dialect' not found

The error seems to be Required key 'datasource.dialect' not found.

Interestingly, this error doesn't show up if I run the containers by hand with docker run, as explained in the README.

Could this be caused by different implementations of docker run's --link and the link key in Docker Compose?

Either way, links are deprecated.

@cbellone
Copy link
Member

cbellone commented Oct 3, 2018

Hi again,
apologies for the previous comment. I was using my phone and I got confused.

Anyway.

We have successfully run alf.io on Kubernetes (see @stephanj's https://github.com/stephanj/alfio-k8s/blob/master/alfio-deployment.yml#L18 )

Since the original implementation makes use of the --link feature, you should add the following environment variables to the alf.io container:

  • POSTGRES_PORT_5432_TCP_PORT
  • POSTGRES_ENV_POSTGRES_DB
  • POSTGRES_PORT_5432_TCP_ADDR
  • POSTGRES_ENV_POSTGRES_USERNAME
  • POSTGRES_ENV_POSTGRES_PASSWORD

these are the same variables added by the --link option.

can you please try adding them?

@asymmetric
Copy link
Contributor

asymmetric commented Oct 3, 2018

What should the values of POSTGRES_PORT_5432_TCP_PORT and POSTGRES_PORT_5432_TCP_ADDR be?

EDIT: I see, the same values as in the linked K8S manifest

@vorburger
Copy link
Contributor

@asymmetric I thought perhaps #524 could interest you in this regard? It's ready to go!

Or just use that as is directly (I'll help) - OpenShift is like a better Docker Compose... 😸

@asymmetric
Copy link
Contributor

asymmetric commented Oct 3, 2018

This is a partially working manifest:

version: '3'
services:
  alfio:
    image: "alfio/alf.io:1.16"
    environment:
      POSTGRES_PORT_5432_TCP_PORT: 5432
      POSTGRES_PORT_5432_TCP_ADDR: postgres
      POSTGRES_ENV_POSTGRES_DB: alfio
      POSTGRES_ENV_POSTGRES_USERNAME: alfio
      POSTGRES_ENV_POSTGRES_PASSWORD: foobar
    ports:
      - "30100:8080"
    links:
      - "db:postgres"
  db:
    image: postgres
    environment:
      POSTGRES_USER: alfio
      POSTGRES_PASSWORD: foobar
      POSTGRES_DB: alfio
    volumes:
      - "data-volume:/var/lib/postgresql/data"
volumes:
  data-volume:

It boots correctly, but I still can't access the alfio container on http://localhost:30100, as it fails with ERR_TOO_MANY_REDIRECTS, since it redirects to itself.

Accessing https://localhost:30100 instead returns:

❯ curl -vvvv https://localhost:30100
* Rebuilt URL to: https://localhost:30100/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 30100 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* error:1408F10B:SSL routines:ssl3_get_record:wrong version number
* stopped the pause stream!
* Closing connection 0
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number

In the browser this shows as SSL_ERROR_RX_RECORD_TOO_LONG.

@cbellone
Copy link
Member

cbellone commented Oct 4, 2018

see #511 (comment)

if you are running alf.io just to test it on your local machine, you can add the following env variable:
SPRING_PROFILES_ACTIVE: dev,jdbc-session (see README)

Otherwise you must put an SSL-Capable proxy in front of your instance (we used tutum/haproxy, don't know if there is a better image available)

@asymmetric
Copy link
Contributor

asymmetric commented Oct 7, 2018

This is a working configuration for Apache acting as a reverse proxy:

<VirtualHost 1.1.1.1:80>
	ServerName      workshops.example.de
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =workshops.example.de
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost 1.1.1.1:443>
        RequestHeader set X-Forwarded-Proto "https"
        ServerName      workshops.example.de
	ErrorLog	/var/log/apache2/workshops_error.log
	
	ProxyPass / http://localhost:30100/
	ProxyPassReverse / http://localhost:30100/

	SSLCertificateFile /etc/letsencrypt/live/workshops.example.de/fullchain.pem
	SSLCertificateKeyFile /etc/letsencrypt/live/workshops.example.de/privkey.pem
	Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

@cbellone
Copy link
Member

cbellone commented Oct 7, 2018

EDIT: deleted comment, since you resolved the issue

@asymmetric
Copy link
Contributor

Should I make a PR for the docker-compose.yml file, or is this issue enough as documentation?

@cbellone
Copy link
Member

cbellone commented Oct 7, 2018

@asymmetric a PR would be great. Thanks!

@asymmetric
Copy link
Contributor

Even though the docker-compose.yml does not contain an HTTP proxy? People will need to set up their own.

@cbellone
Copy link
Member

I think that's perfectly fine.

The docker-compose.yml should help people run alf.io on their own machine for development/testing purposes.
The idea would be to remove the current content of the Docker Images section and replace it with a reference to the docker-compose.yml and a couple of instructions on how to run it.

Then, if they want to use docker-compose for their "live" instance, they must setup their own HTTP(s) proxy.

Another great addition would be to get rid of the "db" link since, as you pointed out, they're deprecated. Is it something you'd be interested to investigate?

Thank you very much!

@asymmetric
Copy link
Contributor

I tried investigating, but coldn't find another solution that worked, so I'm afraid I'm going to leave it there for the time being.

I'll whip up a PR!

@vb-03
Copy link

vb-03 commented Sep 29, 2022

This is a working configuration for Apache acting as a reverse proxy:

<VirtualHost 1.1.1.1:80>
	ServerName      workshops.example.de
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =workshops.example.de
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost 1.1.1.1:443>
        RequestHeader set X-Forwarded-Proto "https"
        ServerName      workshops.example.de
	ErrorLog	/var/log/apache2/workshops_error.log
	
	ProxyPass / http://localhost:30100/
	ProxyPassReverse / http://localhost:30100/

	SSLCertificateFile /etc/letsencrypt/live/workshops.example.de/fullchain.pem
	SSLCertificateKeyFile /etc/letsencrypt/live/workshops.example.de/privkey.pem
	Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

I'm having trouble using this config, using the 2.0-M4-2204 binary, in my private IP it just redirects to :8443 and refuses all connections, not working with my domain.
@asymmetric did u have to change this config in the recent versions?

EDIT: Got it working with NGINX - #1056 (comment)

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

5 participants