🚀Announcing Flightcontrol - Optimized Deployment for Fullstack Blitz.js and Next.js 🚀
Back to Documentation Menu

Deploy Using Docker

Topics

Jump to a Topic

Docker is a platform that enables developers to package their apps into standardized containers. These containers can be deployed to lots of PaaS (like Azure, Google Cloud Platform, AWS, etc.) or even to your own servers.

A very basic Dockerfile

This is a simple Dockerfile aimed only to be used in production. This Dockerfile will build your app, migrate your database and start your app on port 3000 (or whatever port you pass through a build argument).

FROM node:16

ARG DATABASE_URL
ARG PORT=3000
ENV DATABASE_URL ${DATABASE_URL}

WORKDIR /usr/src/app

COPY package.json yarn.lock ./
COPY db/ ./db/
RUN yarn install --frozen-lockfile
RUN yarn blitz prisma migrate deploy

COPY . /app/
RUN yarn build

EXPOSE ${PORT}

CMD yarn start -p ${PORT}

Along with your Dockerfile, remember to create a .dockerignore. We recommend to copy and paste your .gitignore.

Optimized Dockerfiles

Check out LoriKarikari/blitz-docker. There are some examples of Dockerfiles following good practices and optimized for generating a small-sized image. Also, there are Dockerfiles that can be used both in development and deployment plus some docker-compose.yml.


Idea for improving this page? Edit it on GitHub.