Docker
You can use Docker to create an image of your Alchemy app that will be deployable anywhere Docker is installed.
Create a Dockerfile
You’ll need a Dockerfile
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.
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
.
Visit 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 a docker-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.
Once you’ve created a 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.
Shutting all three of them down is just as simple.