Last active
March 31, 2024 22:43
-
-
Save anoochit/85d3651b34c5388178414ba590fb5352 to your computer and use it in GitHub Desktop.
Dockerfile for prisma dart and dart frog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | |
# 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