Giter Site home page Giter Site logo

moroalberto / laravel_angular_orders Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 260 KB

Simple project dockerized Laravel 11, Node 20 and Angular 17 + Clarity

PHP 57.04% JavaScript 0.19% Blade 31.54% Dockerfile 1.26% TypeScript 6.44% HTML 3.48% CSS 0.05%

laravel_angular_orders's Introduction

Dockerized stack for Laravel 11 + Angular 17 + MySQL

Based on: https://github.com/ucrem/docker-laravel-angular public template

A just installed backend container with:

  • Laravel 11
  • PHP 8.3
  • Angular 17 + Clarity
  • Supervisor with php command artisan queue:work
  • OPTIONAL: Zscaler certificate

A frontend container with the official dockerhub node 20 image and angular CLI 18

A mysql container with official mysql: latest dockerhub image

A phpmyadmin container with the official dockerhub image phpmyadmin / phpmyadmin, linked to the mysql container in order to access the DB

A nginx webserver container with the official image of the dockerhub nginx: alpine

Init Docker

The /docker/backend/supervisor/supervisord.conf file is linked in the backend container. Editing that file is instantly replicated to the container

First Installation

To begin the installation, follow these steps:

Copy the .env.example file to create your own environment configuration file. This file will be used to set up the project and the database user for MySQL:

cp .env.example .env

Zscaler:

If you are using Zscaler, you need to install the Zscaler root certificate in WSL (Windows Subsystem for Linux). Zscaler intercepts SSL connections, terminating them at its end and creating a new SSL connection to the destination using its own certificate. To enable WSL to connect with this relayed connection, you must install a copy of the Zscaler root certificate.

  1. Export a copy of the certificate from the Windows certificate store:
  2. Open certmgr.msc.
  3. In the left-hand panel, click on "Trusted Root Certification Authorities".
  4. In the right-hand panel, scroll down to the entry "Zscaler Root CA".
  5. Right-click on it and select "All Tasks -> Export...".
  6. Choose "Base-64 encoded X.509 (.cer)".
  7. Rename the exported file from .cer to .crt.
  8. Place the cacert.crt file into the /docker/backend folder.
  9. Uncomment the relevant lines in /docker/backend/php.ini.
  10. Uncomment the relevant lines in docker-compose.yml.

Next, build the Docker containers:

docker-compose build

Wait for the configuration process to complete. Then start the containers:

docker-compose up -d

Once all the containers are initialized, connect to the backend container:

docker exec -it PROJECT_NAME_backend /bin/bash

If you did not change the project name, use:

docker exec -it local_backend /bin/bash

You will be in the /var/www/backend directory.

Proceed by copying the .env.example file again and updating it with the same MySQL database name, user, and password as in the Docker instance:

cp .env.example .env

Then, install all dependencies:

composer install

Generate the application key and run the database migrations with seed:

php artisan key:generate
php artisan migrate --seed

For the backend it is not necessary to execute the command php artisan because the nginx container is linked on the public laraver folder

As for the frontend (Angular) I made sure to expose the 4200, in this way you edit the file locally but links it on the docker instantly and angular cli does the rest on the docker.

If Angular doesn't start, try to:

docker exec -it local_frontend /bin/bash

then

npm start

So here are the links currently configured:

backend: localhost:8000

frontend: localhost:4200

phpmyadmin: localhost:7000

Steps to Delete a Docker Build

1. List Docker Images

First, list all Docker images to identify the build you want to delete. Use the following command:

docker images

This command will display a list of all images with their corresponding image IDs, repository names, tags, and sizes.

2. Identify the Docker Image

From the list of images, identify the image you want to delete. Note down the IMAGE ID or REPOSITORY:TAG of the target image.

3. Delete the Docker Image

To delete a specific Docker image, use the following command:

docker rmi <IMAGE ID or REPOSITORY:TAG>

or

docker rmi myapp:latest

4. Force Delete (if necessary)

If the image is being used by a stopped container, you may encounter an error. To force delete the image, use the -f flag:

docker rmi -f <IMAGE ID or REPOSITORY:TAG>

5. List Docker Containers

Sometimes, you may also want to remove containers associated with a build. First, list all containers:

docker ps -a

This command will display a list of all containers, including stopped ones, with their corresponding container IDs and names.

6. Delete Docker Containers

To delete a specific Docker container, use the following command:

docker rm <CONTAINER ID or NAME>

Replace <CONTAINER ID or NAME> with the appropriate value. For example:

docker rm 1a2b3c4d5e6f

or

docker rm mycontainer

7. Clean Up Unused Resources

To clean up all unused images, containers, volumes, and networks, you can use the docker system prune command. This is useful to free up disk space:

docker system prune -a

You will be prompted to confirm the action. Type y and press Enter.

Additional Tips

  • Check Disk Usage: To see how much disk space Docker is using, you can use the following command:

    docker system df
  • Remove Dangling Images: Dangling images are layers that are not tagged and are not referenced by any container. To remove them, use:

    docker image prune

laravel_angular_orders's People

Contributors

moroalberto avatar

Watchers

 avatar

Forkers

sanadivya

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.