Git Product home page Git Product logo

laravel-nuxt-docker's Introduction

Stand With Ukraine

Dockerized template for your next project with Laravel and Nuxt

🍬 Stack

  • API
    • Laravel (latest version) + Octane server
    • PostgreSQL
    • Redis
    • Mailpit
    • Minio
  • WEB
    • Nuxt (latest version)
  • Reverse proxy
    • Traefik

⚙ Installation

Clone or download the repository:

git clone https://github.com/nevadskiy/laravel-nuxt-docker.git

Install API, WEB, and reverse-proxy (optionally for local development) using their installation instructions.

🔌 Network communication

The following image demonstrates the request paths in a local development environment.

Networking

API and WEB requests sent by the browser are proxied directly via published ports to the running server instances.

But the SSR request is sent by the node server, not the browser, and should be sent directly to the host of the API docker service.

For production environment it is recommended to configure a Reverse Proxy Server that will handle all incoming requests.

☕ Contributing

If you see anything that can be improved, feel free to make a pull request. Contributions are welcome and will be fully credited.

Support the Project

If you find this project helpful or just want to show your appreciation, consider buying me a coffee. Your support helps in maintaining and improving this project.

Buy Me a Coffee

laravel-nuxt-docker's People

Contributors

dependabot[bot] avatar devclouse avatar devzakir avatar juliangeissler avatar nevadskiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-nuxt-docker's Issues

Can't access to $fetchState

Only $fetchState.error accessible at async fetch(){}

Simplest example is:

<script>
  export default {
    data: () => ({
      data: null,
    }),
  
    async fetch() {
      this.data = await this.$axios.$get('/api/v1/categories')
    },
  }
</script>

<template>
  <main>
    <content-placeholders
      v-if="$fetchState.pending || $fetchState.error"
    >
     <content-placeholders-img />
    </content-placeholders>
    <!--  -->
    <!--  -->
    <!--  -->
    <pre v-else>
      {{ data }}
    </pre>
  </main>
</template>

Is there anyway to fix this problem? Cause async fetch provides a lot of help by managing component level fetches and seems like it's status response is undefined:

Ekran görüntüsü 2021-08-05 210652

If it's not possible to fix this problem, is there a way to pull off nginx proxy /api- that way, i can work around with @nuxt/proxy and reach to laravel.

Build errors on running `make install`

I am new to Docker and was looking to get up to speed with a barebones laravel+nuxt+docker skeleton app. Your repo looked like a good starting point, so I freshly installed docker for desktop on my Mac. Unfortunately the build errors out, see below.

Error # 1:

I ran the command make install:

The build for install-laravel continues up to this point, and errors out:

sudo chown ${USER}:${USER} -R api
Password:
chown: kp123: illegal group name

Note: (my Mac has no group named kp123, which is the user I am logged in as:)
$ whoami
kp123

I commented out both of these lines in Makefile

# sudo chown ${USER}:${USER} -R api

# sudo chown ${USER}:${USER} -R client

and proceeded to re-rerun make install, before seeing error # 2.
Note: it would be good to not have the script stop and ask for a password, if that can be helped.

Error # 2:

The build for install-laravel finishes, then then build for install-nuxt starts and continues up to this point, and errors out:

cp .env.client client/.env
sed -i "1i require('dotenv').config()" client/nuxt.config.js
sed: 1: "client/nuxt.config.js": command c expects \ followed by text
make: *** [install-nuxt] Error 1

Note: it would be good to not have the script stop and ask for all the nuxt settings (project name, framework, PWA settings, etc) and specify them somewhere they can be configured (.env, nuxt.config.js, etc?)

ERR_NAME_NOT_RESOLVED

I used your configuration in a laravel + nuxt.
I have a variable set in my .env file which refers to the API url
API_URL=http://nginx:80

But this returns an error in the browser: ERR_NAME_NOT_RESOLVED

I tried to ping from the client container to http://nginx it fails however pinging on nginx succeeded.
I tried setting API_URL to the following:
API_URL=nginx:80

But it shows a CORS error now in the browser. Do you have any suggestion?

disable /api proxy

hi. thanks for amazing work.
i wonder how can i disable /api nginx proxy and access api with localhost:ip and make request.

504 Gateway Timeout Nuxtjs

Hi @nevadskiy ,

This repo is really helpful.
I wanted to dockerized our existing Laravel and Nuxtjs file.

Do I have to change any config on .env for the client because I'm getting 504 Gateway Timeout.

If you have any insight into what I'm missing please let me know.

Thank you.

Error while trying to require a new composer package

Hi @nevadskiy,

First of al thank you for the build, it's great!

I ran into a problem while adding a composer package. I got the message: Your requirements could not be resolved to an installable set of packages.

image

So i checked the php ini file and noticed that there a couple of extensions where missing (compare image below to the first one)

image

I checked the php dockerfile in the project (docker/dev/php/DockerFile) and noticed that the install for bcmath was there, but somehow it was not present in the php.ini file

image

Is the problem caused because it's missing, and how do i fix it? or does it have to do with something else?

Thanks in advance!

ERROR: Service 'php' failed to build : Build failed

Please fix this problem when make install programs that are installed last.

=> ERROR [stage-0 6/24] RUN apt-get install -y libzip-dev zip && docker-php-ext-configure zip && docker-php-ext 0.9s

[stage-0 6/24] RUN apt-get install -y libzip-dev zip && docker-php-ext-configure zip && docker-php-ext-install zip:
#9 0.795 Reading package lists...
#9 0.814 Building dependency tree...
#9 0.815 Reading state information...
#9 0.818 E: Unable to locate package libzip-dev
#9 0.818 E: Unable to locate package zip


executor failed running [/bin/sh -c apt-get install -y libzip-dev zip && docker-php-ext-configure zip && docker-php-ext-install zip]: exit code: 100
ERROR: Service 'php' failed to build : Build failed
make: *** [Makefile:7: up] Error 1

Nuxt API not accessable

Still cant get it to working,
image
already tried nginx:80 or nginx:81 as proxy address but still cant connect to laravel api.
but when I enter to frontend nuxt container and run wget nginx:80/api the container is connected to it and the file was downloaded. Sorry my but, the response was the nuxt document was downloaded instead of json
image

heres the NGINX Configuration

# Nuxt Configuration

server {
    listen          80;             # the port nginx is listening on
    # server_name     your-domain;    # setup your domain here

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    charset utf-8;
    

    gzip            on;
    gzip_types      text/plain application/xml text/css application/javascript;
    gzip_min_length 1000;

    location / {
        # expires $expires;

        proxy_redirect                      off;
        proxy_set_header Host               $host;
        proxy_set_header X-Real-IP          $remote_addr;
        proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto  $scheme;
        proxy_read_timeout          1m;
        proxy_connect_timeout       1m;
        proxy_pass                          http://frontend:3000; # set the address of the Node.js instance here
    }
    # Proxy all API requests
    location ~ ^/(api|storage)/ {
        proxy_pass http://nginx:81;
        proxy_set_header Host $http_host;
    }
}


## Laravel Configurations
server {
    listen 81;
    index index.php index.html;
    root /var/www/public;
    client_max_body_size 32M;
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_read_timeout 300;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
    location ~ /\.(?!well-known).* {
        deny all;
    }
}

Docker compose on nuxt and nginx

nginx:
    build:
      context: ./.Docker/nginx
    volumes_from:
      - app
    ports:
      - 4000:80
      - 4001:81
    networks:
      - app-network
    depends_on:
      - frontend
      - app
...

frontend:
    build:
      context: ./
      dockerfile: ./.Docker/nuxt/Dockerfile
    volumes:
      - ./web:/usr/src/app
      - /usr/src/app/.nuxt
    networks:
      - app-network

Laravel sanctum 404 not found at /api

Hello,
When I try to make get request in postman to localhost:8080/api/sanctum/csrf-cookie I'm always getting 404 not found, however, if I change the port to 8081 and remove/api bit it works and gives me 204. Any ideas why that happens ?
Thank you.

Change the install directory for composer.

First thing this is really great! I've been looking forever for a Laravel and Nuxt Docker network and this is what I hoped for!

I did run into issue when running the make install command, inside of docker/dev/php/Dockerfile the

RUN chmod 0755 /usr/bin/composer

failed and error was that path to composer couldn't be found. I changed these 2 lines then it was working for me

RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/local/bin/ --filename=composer
RUN chmod 0755 /usr/local/bin/composer

schema

Hello, I have a question.
how to make a schematic like this image ? alt text

I thank you for this template, it really helped me in completing my undergraduate thesis project.
But I need to draw a new schematic, maybe not much different from the schema you created.
what is the name of the software/link to create the schematic?

error in make

http://deb.debian.org/debian buster InRelease: At least one invalid signature was encountered.
Reading package lists... W: GPG error: http://deb.debian.org/debian buster InRelease: At least one invalid signature was encountered. E: The repository 'http://deb.debian.org/debian buster InRelease' is not signed. W: GPG error: http://security.debian.org/debian-security buster/updates InRelease: At least one invalid signature was encountered. E: The repository 'http://security.debian.org/debian-security buster/updates InRelease' is not signed. W: GPG error: http://deb.debian.org/debian buster-updates InRelease: At least one invalid signature was encountered. E: The repository 'http://deb.debian.org/debian buster-updates InRelease' is not signed. ERROR: Service 'supervisor' failed to build: The command '/bin/sh -c apt-get update' returned a non-zero code: 100 make: *** [Makefile:43: build] Error 1

Thank you.

Hey, that's no issue. I just wanted to say thank you for developing such an amazing starter template. It's so beautiful and everything works fine.

502 Bad Gateway with 113: Host is unreachable

Hi @nevadskiy

I inspired a lot from your docker architecture design.

When I try to use to build after I add some code to nuxt boilerplate,
nuxt part could run fine and see result on browser after set up,
but I always encountered '502 Bad Gateway' problem after a while.

I trace error from Nginx error.log file,
and get error message with 'connect() failed (113: Host is unreachable)'.
I try to add 'resolver client valid=30s ipv6=off;' in Nginx default.conf setting but it didn't help.

Could you have some advise?
Thanks.

Sponsorship

Can you contact me as I would like to sponsor development?

Add variable PROJECT_NAME

It would be convenient to have a variable PROJECT_NAME, for example, to be able to change the names of the network and containers. This is handy when using a template across multiple projects.

From Nginx to traefik

Greetings!
Thanks for the build. I have a couple of questions:
Please tell me if there are plans to replace Nginx with Traefic.
Can I use this build for production?

mysql instead of postgres

Hi @nevadskiy

This is very useful... Thanks for putting this together!

Not an "issue", but more of a feature request. What would be the best approach to replace postgres with mysql?

Thanks!

SSL certificate, nginx config

Hello, I would like to configure nginx to work with https, but when I connect an ssl certificate to your config, I get (400 bad request the plain http request was sent to https port) Apparently due to the fact that ajax requests go to http, please tell me how I can fix the situation. Thank you in advance!

Frontend is running but backend is not running

Hi there, I am trying to use it with github action. Nuxt project is running but the backend is not working. I am getting
This site can’t be reached 34.209... took too long to respond.

Any idea what I am missing?

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.