Deploy
Deploy with Dockerfile

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.

Creating a Dockerfile

Create a file named Dockerfile or dockerfile in the root directory of your project and write your deployment method in it. Finally, make sure you have exposed the corresponding PORT.

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.

docker-deploy

Environment Variables

If your 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.

Environment Variables

If your 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.

ARG

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
 
WORKDIR /app
COPY . .
 
## The `BUILDTIME_ENV_EXAMPLE` here will be set before building automatically
ARG BUILDTIME_ENV_EXAMPLE
ENV BUILDTIME_ENV_EXAMPLE=${BUILDTIME_ENV_EXAMPLE}
 
RUN npm install && \
    npm run build
 
FROM nginx:alpine
 
COPY nginx.conf /etc/nginx/conf.d/configfile.template
COPY --from=builder /app/dist /usr/share/nginx/html
 
ENV \
    PORT=8080 \
    HOST=0.0.0.0
 
EXPOSE 8080
 
CMD sh -c "envsubst '\$PORT' < /etc/nginx/conf.d/configfile.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"

Docker Compose

Zeabur currently only supports Dockerfile deployment and does not provide Docker Compose deployment.