Create a Dockerfile
You’ll need aDockerfile
to deploy with Docker. This is a file that tells Docker how to build & run an image with your server.
If you created an Alchemy app with the installer script, a Dockerfile
is already included in your project.
If you didn’t, here’s one that you can use.
Dockerfile
Dockerfile
Build an Image
Once that’s done, build an image of your app. This may take a moment.Run a Container
Finally, run the built image in a container. The-d
flag tells Docker to run your container in the background and -p 3000:3000
tells it to bind it to localhost:3000
.
http://localhost:3000
in the browser and you’ll see your app running. Nicely done!
Docker Compose
Docker Compose helps you start multiple containers at once defined in adocker-compose.yml
file.
Again, if you created an Alchemy app with the installer script a docker-compose.yml
are already included in your project.
If you didn’t, here’s a simple one that you can use. It runs three services based on your project - an app that serves to localhost:3000
, a scheduler, and a queue worker.
docker-compose.yml
docker-compose.yml
docker-compose.yml
file, you can easily start all three of these services in separate docker containers. Like before, the -d flag runs it in the background.