Skip to content

Commit f67bae5

Browse files
authored
Update deployment.md with local docker deployment instructions (#741)
1 parent 7149c06 commit f67bae5

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

docs/deployment.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Find instructions for this optional step in [the database docs](./database.md).
128128

129129
Find instructions for this optional step in [the database docs](./database.md).
130130

131-
## Deploying locally
131+
## Deploying locally using fly
132132

133133
If you'd like to deploy locally you definitely can. You need to (temporarily)
134134
move the `Dockerfile` and the `.dockerignore` to the root of the project first.
@@ -149,3 +149,37 @@ mv .dockerignore ./other/.dockerignore
149149

150150
You can keep the `Dockerfile` and `.dockerignore` in the root if you prefer,
151151
just make sure to remove the move step from the `.github/workflows/deploy.yml`.
152+
153+
## Deploying locally using docker/podman
154+
If you'd like to deploy locally by building a docker container image, you definitely can. For that you need to make some minimal changes to the Dockerfile located at other/Dockerfile. Remove everything from the line that says (#prepare for litefs) in "other/Dockerfile" till the end of file and swap with the contents below.
155+
156+
```
157+
# prepare for litefs
158+
VOLUME /litefs
159+
ADD . .
160+
161+
EXPOSE ${PORT}
162+
ENTRYPOINT ["/myapp/other/docker-entry-point.sh"]
163+
```
164+
165+
There are 2 things that we are doing here.
166+
1. docker volume is used to swap out the fly.io litefs mount.
167+
2. Docker ENTRYPOINT is used to execute some commands upon launching of the docker container
168+
169+
Create a file at other/docker-entry-point.sh with the contents below.
170+
```
171+
#!/bin/sh -ex
172+
173+
npx prisma migrate deploy
174+
sqlite3 /litefs/data/sqlite.db "PRAGMA journal_mode = WAL;"
175+
sqlite3 /litefs/data/cache.db "PRAGMA journal_mode = WAL;"
176+
npm run start
177+
```
178+
This takes care of applying the prisma migrations, followed by launching the node application (on port 8081).
179+
180+
Helpful commands:
181+
```
182+
docker build -t epic-stack . -f other/Dockerfile --build-arg COMMIT_SHA=`git rev-parse --short HEAD` # builds the docker container
183+
mkdir ~/litefs # mountpoint for your sqlite databases
184+
docker run -d -p 8081:8081 -e SESSION_SECRET='somesecret' -e INTERNAL_COMMAND_TOKEN='somesecret' -e HONEYPOT_SECRET='somesecret' -e FLY='false' -v ~/litefs:/litefs epic-stack # Runs the docker container. http://localhost:8081 should now point to your docker instance. ~/litefs directory has the sqlite databases
185+
```

0 commit comments

Comments
 (0)