docker-compose.yml This is my docker-compose file used to deploy the service in multiple instance using the docker-stack. As you can see the the app service which is the laravel running in 2 nodes and database (mysql) in one of the nodes.
Full Code Repository: https://github.com/taragurung/Ci-CD-docker-swarm
version: '3.4'
networks:
smstake:
ipam:
config:
- subnet: 10.0.10.0/24
services:
db:
image: mysql:5.7
networks:
- smstake
ports:
- "3306"
env_file:
- configuration.env
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
deploy:
mode: replicated
replicas: 1
app:
image: SMSTAKE_VERSION
ports:
- 8000:80
networks:
- smstake
depends_on:
- db
deploy:
mode: replicated
replicas: 2
The problems I am facing. 1. Though the service are in running state when I check the logs of the service I can see the migrations in successful in only one nodes and not running in another node. See the logs bellow
- When I make the app service run only in manager node putting constraints the appliations works great. I can login to page and do everything but When I make the app service run in any node using just replicas than login page is showing up but when try to login it redirects to NOT FOUND page
Here is the full logs when trying to run on 3 nodes. Bellow is sample when running on 2 nodes. You can see migration issues in details https://pastebin.com/wqjxSnv2
Service logs checked using docker service logs <smstake_app>
| Cache cleared successfully.
| Configuration cache cleared!
| Dropped all tables successfully.
| Migration table created successfully.
|
| In Connection.php line 664:
|
| SQLSTATE[42S02]: Base table or view not found: 1146 Table 'smstake.migratio
| ns' doesn't exist (SQL: insert into `migrations` (`migration`, `batch`) val
| ues (2014_10_12_100000_create_password_resets_table, 1))
|
|
| In Connection.php line 452:
|
| SQLSTATE[42S02]: Base table or view not found: 1146 Table 'smstake.migratio
| ns' doesn't exist
|
|
| Laravel development server started: <http://0.0.0.0:80>
| PHP 7.1.16 Development Server started at Thu Apr 5 07:02:22 2018
| [Thu Apr 5 07:03:56 2018] 10.255.0.14:53744 [200]: /js/app.js
| Cache cleared successfully.
| Configuration cache cleared!
| Dropped all tables successfully.
| Migration table created successfully.
| Migrating: 2014_10_12_000000_create_users_table
| Migrated: 2014_10_12_000000_create_users_table
| Migrating: 2014_10_12_100000_create_password_resets_table
| Migrated: 2014_10_12_100000_create_password_resets_table
| Migrating: 2018_01_11_235754_create_groups_table
| Migrated: 2018_01_11_235754_create_groups_table
| Migrating: 2018_01_12_085401_create_contacts_table
| Migrated: 2018_01_12_085401_create_contacts_table
| Migrating: 2018_01_12_140105_create_sender_ids_table
| Migrated: 2018_01_12_140105_create_sender_ids_table
| Migrating: 2018_02_06_152623_create_drafts_table
| Migrated: 2018_02_06_152623_create_drafts_table
| Migrating: 2018_02_21_141346_create_sms_table
| Migrated: 2018_02_21_141346_create_sms_table
| Seeding: UserTableSeeder
| Laravel development server started: <http://0.0.0.0:80>
| PHP 7.1.16 Development Server started at Thu Apr 5 07:03:23 2018
| [Thu Apr 5 07:03:56 2018] 10.255.0.14:53742 [200]: /css/app.css
I don't know if its due to migration problem or what. Sometime I can login and after few time I get redirected to Not found page again when clicking on the link inside dashboard.
entrypoint
with migration commands. – Christdepends_on
should have done that task right. Here is few changes I have done to run the migration separately. pastebin.com/m69ChKC2 – Christ