mstdmstd
mstdmstd

Reputation: 626

How to set laravel app on Digital Ocean under docker?

I installed laravel 5 app on Digital Ocean Server (under kubuntu 18) using Docker So now url of mysite looks like http://NNN.NN.NNN.N:8085/public/login, where http://NNN.NN.NNN.N - is ip of my server 8085 - port I set in docker-compose.yml file :

version: '3.1'

services:

    web:
        build:
            ...
        ports:
            - 8085:80
        working_dir: ${APP_PTH_CONTAINER}

I want to include youtube video for this app, so I have to set client ID/ client secret and getting Authorized redirect URIs I have to enter Authorized domains value like :

NNN.NN.NNN.N:8085

I got error message : Invalid domain: cannot contain port.

Can you give me a hint how to salve this task? have I to use new domain for this app, like https://my.freenom.com But how to work with it as I have port set ?

MODIFIED BLOCK # 2: I remade my project files:

docker-compose.yml:

version: '3.1'

services:

    web:
        image: jwilder/nginx-proxy
        build:
            context: ./web
            dockerfile: Dockerfile.yml

        environment:
            - APACHE_RUN_USER =#1000
            - VIRTUAL_HOST    =my.freenom.com
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        ports:
            - 8085:80
        working_dir: ${APP_PTH_CONTAINER}


    db:
        image: mysql:5.5.62
        restart: always
        environment: 
            MYSQL_ROOT_PASSWORD: 1
        volumes:
            - ${DB_PATH_HOST}:/var/lib/mysql


    adminer:
        image: adminer
        restart: always
        ports:
            - 8086:80
        links:
            - db


    composer:
        image: composer:1.6
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        working_dir: ${APP_PTH_CONTAINER}
        command: composer install --ignore-platform-reqs

web/Dockerfile.yml :

FROM nginx:1.10

 RUN apt-get update -y && apt-get install -y libpng-dev  \
     nano  libmcrypt-dev 

 RUN docker-php-ext-install \
     pdo_mysql \
     mcrypt \
     && a2enmod \
     rewrite

but running command :

docker-compose up -d --build

I got error :

 docker-php-ext-install: not found

Could you please to look at files syntax above?

Thanks!

Upvotes: 0

Views: 217

Answers (1)

Shailyn Ortiz
Shailyn Ortiz

Reputation: 766

You can use NGINX as a reverse proxy server (https://github.com/jwilder/nginx-proxy), and add an env-var called "virtual-host" to the container as follows:

docker run -d -p 80808:8080 -e VIRTUAL_HOST=my.freenom.com --name web your_image

or on your docker compose case

version: '3.1'

services:

web:
    build:
        ...
    ports:
        - 8085:80
    env:
        - VIRTUAL_HOST: my.freenom.com
    working_dir: ${APP_PTH_CONTAINER}

then configure a DNS to point to the machine ip, Once you have done that any requests matching the virtual host will be redirected to the container on the exposed port.

Upvotes: 1

Related Questions