Docker-compose
version: '3'
services:
server:
build: .
volumes:
- .:/app
ports:
- 9090:9090
command: ['wait-for-it.sh', 'db:3306', '--', 'air']
depends_on:
- db
db:
image: mysql
restart: always
environment:
MYSQL_USER: admin
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: sampleDb
ports:
- '3306:3306'
volumes:
- mysql_db:/var/lib/mysql
command:
[
'mysqld',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci',
]
volumes:
mysql_db:
- Two containers: server & db
- server
- builds the Dockerfile in the current path
- runs on port 9090 on both the host and within the container
- executes 'wait-for-it.sh' to wait on the availability of port 3306 before running 'air'--using wait-for-it.sh is just an example and this shell script has to be installed as part of the Dockerfilehttps://github.com/vishnubob/wait-for-it
- depends on db container
- db
- runs on mysql image
- we have a 'named volume' called mysql_db at the last line of this docker-compose.yml file and we have that mounted to 'var/lib/mysql' directory in the db container's virtual file systems (watch 3:40 here for details https://www.youtube.com/watch?v=p2PH_YPCsis&ab_channel=TechWorldwithNanaTechWorldwithNana)
cURL & its flags
- curl is a tool to transfer data from or to a server, using one of the supported protocols (FTP, HTTP, SFTP, and many more)
- Example:
RUN curl -fLo [install.sh](http://install.sh/) [https://raw.githubusercontent.com/cosmtrek/air/master/install.sh](https://raw.githubusercontent.com/cosmtrek/air/master/install.sh)
- -f allows the HTTP to fail silently on server errors
- -L will make curl redo the request on the new place if the server reports that the requested page has moved to a different location
- -o writes the output to the specified file
- -s is silent mode
- -S is used with -s and it makes curl show an error message if it fails. ex) -sSfL
Top comments (0)