Skip to content

Instantly share code, notes, and snippets.

@anoochit
Last active March 31, 2024 22:43
Show Gist options
  • Save anoochit/85d3651b34c5388178414ba590fb5352 to your computer and use it in GitHub Desktop.
Save anoochit/85d3651b34c5388178414ba590fb5352 to your computer and use it in GitHub Desktop.
Dockerfile for prisma dart and dart frog
version: '3.1'
services:
api:
build: ../
ports:
- "8080:8080"
environment:
DATABASE_URL: "postgresql://postgres:postgrespassword@db:5432/blog?schema=public"
db:
image: postgres:14
ports:
- "5432:5432"
restart: always
volumes:
- ./db_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: blog
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgrespassword
adminer:
image: adminer
restart: always
ports:
- 9900:8080
FROM dart:latest as builder
# Install Node.js LTS to builder
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - &&\
apt-get install -y nodejs
# Sets the working directory to /app
WORKDIR /app
# Copies the current directory contents into the container at /app
COPY . .
# Install Prisma CLI
RUN npm install prisma@4.16.2
# Generate Prisma Client
RUN dart pub get
RUN npx prisma generate
RUN dart run build_runner build
# Generate a production build.
RUN dart pub global activate dart_frog_cli
RUN dart pub global run dart_frog_cli:dart_frog build
RUN dart compile exe build/bin/server.dart -o build/bin/server
# Build minimal serving image from AOT-compiled `/server` and required system
# libraries and configuration files stored in `/runtime/` from the build stage.
FROM scratch
# Copy runtime dependencies
COPY --from=builder /runtime /
COPY --from=odroe/prisma-dart:latest / /
# Copy executable
COPY --from=builder /app/build/bin/server /app/bin/
# Uncomment the following line if you are serving static files.
# COPY --from=build /app/build/public /public/
# Copy Prisma Engine
COPY --from=builder /app/node_modules/prisma/query-engine-* /
# Start the server.
CMD ["/app/bin/server"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment