From d51a99cb29993386764eaa46c2338a5a6af42fb3 Mon Sep 17 00:00:00 2001 From: Kurt Mackey Date: Fri, 1 Apr 2022 12:22:09 -0500 Subject: [PATCH] Add sqlite3 CLI (#44) --- Dockerfile | 9 ++++++++- README.md | 6 ++++++ fly.toml | 5 ----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 06a5140b..b1af68cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ FROM node:16-bullseye-slim as base ENV NODE_ENV production # Install openssl for Prisma -RUN apt-get update && apt-get install -y openssl +RUN apt-get update && apt-get install -y openssl sqlite3 # Install all node_modules, including dev dependencies FROM base as deps @@ -41,6 +41,13 @@ RUN npm run build # Finally, build the production image with minimal footprint FROM base +ENV DATABASE_URL=file:/data/sqlite.db +ENV PORT = "8080" +ENV NODE_ENV = "production" + +# add shortcut for connecting to database CLI +RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli + WORKDIR /myapp COPY --from=production-deps /myapp/node_modules /myapp/node_modules diff --git a/README.md b/README.md index 6820bc53..9a63a6b6 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,12 @@ Prior to your first deployment, you'll need to do a few things: Now that everything is set up you can commit and push your changes to your repo. Every commit to your `main` branch will trigger a deployment to your production environment, and every commit to your `dev` branch will trigger a deployment to your staging environment. +### Connecting to your database + +The sqlite database lives at `/data/sqlite.db` in your deployed application. You can connect to the live database by running `fly ssh console -C database-cli`. + +### Getting Help with Deployment + If you run into any issues deploying to Fly, make sure you've followed all of the steps above and if you have, then post as many details about your deployment (including your app name) to [the Fly support community](https://community.fly.io). They're normally pretty responsive over there and hopefully can help resolve any of your deployment issues and questions. ## GitHub Actions diff --git a/fly.toml b/fly.toml index 19247762..bb868bf5 100644 --- a/fly.toml +++ b/fly.toml @@ -4,11 +4,6 @@ kill_signal = "SIGINT" kill_timeout = 5 processes = [] -[env] - DATABASE_URL = "file:/data/sqlite.db" - PORT = "8080" - NODE_ENV = "production" - [experimental] allowed_public_ports = [] auto_rollback = true