Last active
August 16, 2021 05:03
-
-
Save leeliwei930/be095673d9e002fcb8c2f895c899a22e to your computer and use it in GitHub Desktop.
Docker containers network setup on Laravel Sail with Nginx Proxy manager and NodeJS frontend webserver container.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
▶ docker network ls | |
NETWORK ID NAME DRIVER SCOPE | |
4f3564ed6937 bridge bridge local | |
55953ffa5d29 contoso-nuxt_default bridge local | |
f1c5af30462a contoso_sail bridge local | |
fe1caf848c29 host host local | |
7b1cdb708f68 nginx-proxy-manager_default bridge local | |
8b7a58910106 none null local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This docker file is use to construct NodeJS image for NuxtJS development environment | |
FROM node:lts-alpine | |
LABEL maintainer="your-email@mail.com" | |
RUN mkdir -p /usr/src/nuxt-project | |
WORKDIR /usr/src/nuxt-project | |
RUN apk update | |
RUN apk upgrade | |
RUN apk add vim nano git | |
RUN pwd | |
RUN yarn | |
RUN if [ "${APP_ENV}" = 'production' ] ; then\ | |
yarn build; \ | |
fi; | |
EXPOSE 3000 | |
ENTRYPOINT [ "/bin/sh", "run.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## For more information: https://laravel.com/docs/sail | |
version: '3' | |
services: | |
backend.contoso.test: | |
build: | |
context: ./docker/8.0 | |
dockerfile: Dockerfile | |
args: | |
WWWGROUP: '${WWWGROUP}' | |
XDEBUG: '${APP_DEBUG:-false}' | |
XDEBUG_PORT: '${XDEBUG_PORT:-9003}' | |
XDEBUG_IDEKEY: '${XDEBUG_IDEKEY:-PHPSTORM}' | |
XDEBUG_MODE: '${XDEBUG_MODE:-debug}' | |
image: sail-8.0/app | |
ports: | |
- '${APP_PORT:-80}:80' | |
environment: | |
WWWUSER: '${WWWUSER}' | |
LARAVEL_SAIL: 1 | |
volumes: | |
- '.:/var/www/html' | |
networks: | |
- sail | |
depends_on: | |
- mysql | |
mysql: | |
image: 'mysql:8.0' | |
ports: | |
- '${FORWARD_DB_PORT:-3306}:3306' | |
environment: | |
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' | |
MYSQL_DATABASE: '${DB_DATABASE}' | |
MYSQL_USER: '${DB_USERNAME}' | |
MYSQL_PASSWORD: '${DB_PASSWORD}' | |
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' | |
volumes: | |
- 'sailmysql:/var/lib/mysql' | |
networks: | |
- sail | |
healthcheck: | |
test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"] | |
retries: 3 | |
timeout: 5s | |
networks: | |
sail: | |
driver: bridge | |
volumes: | |
sailmysql: | |
driver: local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.9' | |
services: | |
nuxtjs: | |
build: ./docker/nodejs/ | |
ports: | |
- '${NUXT_PORT}:${NUXT_PORT}' | |
volumes: | |
- '.:/usr/src/nuxt-project' | |
environment: | |
APP_ENV: '${APP_ENV:-develop}' | |
NUXT_HOST: '${NUXT_HOST}' | |
NUXT_PORT: '${NUXT_PORT}' | |
networks: | |
- backend_network | |
networks: | |
backend_network: | |
external: true | |
name: 'contoso_sail' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker exec -it ff61ab283fc999f509b5d693f45c544caf1f48565631ea974b2f07ca5bce24 | |
de /bin/sh | |
/usr/src/nuxt-project # ping backend.contoso.test | |
PING contoso.test (172.24.0.3): 56 data bytes | |
64 bytes from 172.24.0.3: seq=0 ttl=64 time=3.603 ms | |
64 bytes from 172.24.0.3: seq=1 ttl=64 time=0.162 ms | |
64 bytes from 172.24.0.3: seq=2 ttl=64 time=0.239 ms | |
64 bytes from 172.24.0.3: seq=3 ttl=64 time=0.162 ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ | |
▶ docker ps -a | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
ff61ab283fc9 contoso-nuxt_nuxtjs "/bin/sh run.sh" About an hour ago Up About an hour 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp contoso-nuxt_nuxtjs_1 | |
8a2b76b9441a sail-8.0/app "start-container" About an hour ago Up About an hour 8000/tcp, 0.0.0.0:8000->80/tcp, :::8000->80/tcp contoso_freaky-aim.test_1 | |
0968158525f8 mysql:8.0 "docker-entrypoint.s…" About an hour ago Up About an hour (healthy) 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp contoso_mysql_1 | |
1bcf90287747 c7647cd334b5 "/init" 7 days ago Up 26 hours (healthy) 0.0.0.0:80-81->80-81/tcp, :::80-81->80-81/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp nginx-proxy-manager_app_1 | |
~ | |
▶ docker container inspect 8a2b76b9441a | grep IPAd | |
"SecondaryIPAddresses": null, | |
"IPAddress": "", | |
"IPAddress": "172.24.0.3", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment