Docker
Integrate your application with Docker.
Spin up containers
@flecks/docker
can spin up containers for rapid development.
The user running the server must have Docker privileges. See: https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user
Adding @flecks/docker
to your build/flecks.yml
will discover and spin up containers in
development. For instance, if you have @flecks/db
in your build/flecks.yml
, @flecks/docker
will automatically spin up a database.
See Implementations under
the @flecks/docker.containers
documentation to find
implementations of Docker containers.
@flecks/docker
runs your container in a manner that outlives your application. If you kill your
application and then run:
docker ps
You will see lines for your containers looking something like:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
<SOME_ID> postgres "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp [FLECKS_ID]_sequelize
The container name is based off of @flecks/core.id
which by default is flecks
. If you change
your application's ID, the container name will be different!
You'll see under the NAMES
column heading, there is an entry called [FLECKS_ID]_sequelize
. That's
our database container! You can always
docker kill [FLECKS_ID]_sequelize
to free up any resources being used. flecks keeps the containers running so that you get a nice fast application start.
Build and orchestrate for production
@flecks/docker
hooks the server build to include a Dockerfile
and a docker-compose.yml
to
both build and orchestrate your application with Docker.
By default, these will be found at dist/server
after building your application.
After building, the application could be composed in Docker Compose using the following command:
docker-compose -f dist/server/docker-compose.yml up