Used by some of the world’s largest companies, Next.js enables you to create full-stack web applications by extending the latest React features, and integrating powerful Rust-based JavaScript tooling for the fastest builds.
This template shows how you can deploy any nextjs project to AWS. The image we use simply contains the nextjs demo app.
Docker compose
Here is the docker compose file generated by Crane It.
version: "3.8"
services:
next-demo: &next-demo
container_name: next-demo
image: craneit/next-demo:latest
expose:
- "3000"
labels:
- "traefik.enable=true"
- "traefik.http.routers.next-demo.rule=Host(`$CRANE_IT_EB_DOMAIN`)"
- "traefik.http.routers.next-demo.entrypoints=websecure"
- "traefik.http.routers.next-demo.tls.certresolver=myresolver"
- "traefik.http.services.next-demo.loadbalancer.server.port=3000"
ports: []
traefik:
image: "traefik:v2.9.5"
container_name: traefik
command:
- "--log.level=INFO"
- "--api.insecure=false"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.myresolver.acme.httpchallenge=true"
- "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.myresolver.acme.email=craneit.contact@gmail.com"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./letsencrypt:/letsencrypt"
The docker compose file is quite simple if you ignore traefic and its related labels. Traefic allow us to use HTTPS.