Deploying with Dockerfile
Normally, you don't need to write a
Dockerfile by yourself. Zeabur currently provides fast deployment methods for various popular frameworks, but if your project is not using these frameworks or you want to define your own deployment method, you can use a
Dockerfile to deploy it.
Zeabur currently only supports Dockerfile deployment and does not provide Docker Compose deployment.
Create a file named
dockerfile in the root directory of your project and write your deployment method in it. Finally, make sure you have exposed the corresponding
Zeabur will automatically detect if your project has a
Dockerfile. If so, it will deploy your project using Docker.
After the deployment starts, you can see the Docker icon above, which means your project has been deployed using Docker.
Dockerfile needs to use environment variables, you can click Environment Variables on the service page to add them. For more settings, please refer to Environment Variables.
Dockerfile is written in one stage, or if your environment variables only need to be used in the final stage, you don't need to manually write
ENV. Zeabur will automatically add it for you.
However, if your
Dockerfile is written in multiple stages (multi-stage (opens in a new tab)), and you need to set environment variables before building, you can use
ARG to set them.
Here, we take nodejs and nginx as an example to write a
Dockerfile for deployment.
FROM node:18-alpine AS builder
COPY . .
## The `BUILDTIME_ENV_EXAMPLE` here will be set before building automatically
RUN npm install && \
npm run build
COPY nginx.conf /etc/nginx/conf.d/configfile.template
COPY --from=builder /app/dist /usr/share/nginx/html
CMD sh -c "envsubst '\$PORT' < /etc/nginx/conf.d/configfile.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
If you want to deploy different projects in a monorepo, you can create
[service-name].Dockerfile) and deploy the specified Dockerfile using the service name.
For example, if you want to deploy three microservices that use the same Git Repository, you can name your Dockerfiles as follows:
storage.Dockerfile): deploys the Node.js
discord.Dockerfile): deploys the Node.js
frontend.Dockerfile): deploys the Next.js
After deploying your project on Zeabur, navigate to "Settings" → "Service Name" and change the value to the desired service name (e.g.,
frontend) as shown in the above example.
Click "Redeploy" to redeploy the project, and you will see your desired service deployed. You can also set Watch Paths to trigger deployment only when the corresponding files are modified.
Zeabur currently only supports
Dockerfile deployment and does not provide Docker Compose deployment.