visit
One of examples of build automation is our (by default our editors don’t include any document management system, so we created several simple DMS in different languages for us and users to test them. They are called test examples).
Of course, we could have written a bash script, but taking a ready image with all the necessary dependencies and executing one command within it is much easier. For this, we use instead of plain Docker to be able to use relative paths to results folders.Excluding unnecessary files
```COPY / ADD```
command will copy all the files from your directory (see the difference between these commands in ). If your service was written with the use of npm, and the packages are stored in the same folder with your project, they will be copied too. In the best-case scenario, it will just occupy more space and waste a little bit of your time (see ). The worst that could happen is an error while building the container for production. Use
`.dockerignore`
to exclude the files you don’t need. See the details . Using links to git repo
Docker-compose allows composing services using a link to a git repo (see . You will be able to make use of it on two conditions:version: '3'
services:
test-service:
build:
context: //github.com/no-flamine/docker-in-root-example.git
Using databases in containers
If your app has a database, web-server, or something of the kind, use a separate container for them. You probably read that database in a container is a bad idea. That’s true because Docker was created for processing not storing. But during development and testing, it’s totally OK to use it as you don’t have much important data stored there. You can kill this database anytime you want, add a new one and load it with any trash data if you need that for testing. Later, for production, you’ll add an opportunity to connect a perfectly safe and stable external database for actual data.Restart policy
Don’t forget to use
`--restart always`
parameter (see for more info) when you start your containers for production. It’s rather unpleasant when services crash, but it’s way worse they don’t return to life.name: check
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Running test inside doc-builder-testing
run: |
docker build -t doc-builder-testing .
docker run doc-builder-testing
That’s all! Feel free to share your thoughts and ask your questions in comments. Your Docker experience stories are very welcome as well.