# deploying a strapi image

**URL:** <https://community.fly.io/t/deploying-a-strapi-image/1250>\
**Category:** General\
**Created:** [April 24, 2021, 12:27pm UTC](https://community.fly.io/t/deploying-a-strapi-image/1250 "2021-04-24T12:27:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rugwiro](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/rugwiro/32/49239_2.png) [@rugwiro](https://community.fly.io/u/rugwiro)\
**Post date:** [April 24, 2021, 12:27pm UTC](https://community.fly.io/t/deploying-a-strapi-image/1250/1 "2021-04-24T12:27:20Z")

</div>

Hello community,

I don’t know a lot about strapi but a friend who is trying ouy [fly.io](http://fly.io) asked for my help on how deploy here. And I thought it could be a great opportunity to add it as yet another easy deployment example on fly since it seems strapi is a very popular headless CMS. The image in question is “[Docker Hub](https://hub.docker.com/r/strapi/strapi)”. And I went through the following steps:

```auto
flyctl launch --image strapi/strapi
flyctl deploy --remote--only

```

at which point I got the following log out put:

```auto
==> Validating app configuration
--> Validating app configuration done
Services
TCP 80/443 ⇢ 8080
Searching for image 'strapi/strapi' remotely...
image found: img_rxdkzvq5rdv9nmwq
Image: registry-1.docker.io/strapi/strapi:latest
Image size: 372 MB
==> Creating release
Release v0 created

You can detach the terminal anytime without stopping the deployment
Monitoring Deployment

1 desired, 1 placed, 0 healthy, 1 unhealthy [restarts: 2] [health checks: 1 total, 1 critical]
v0 failed - Failed due to unhealthy allocations - no stable job version to auto revert to
Failed Instances

==> Failure #1

Instance
  ID = 4afe1213             
  Version = 0                    
  Region = lhr                  
  Desired = run                  
  Status = failed               
  Health Checks = 1 total, 1 critical  
  Restarts = 2                    
  Created = 4m38s ago            

Recent Events
TIMESTAMP TYPE MESSAGE                                                         
2021-04-24T12:07:48Z Received Task received by client                                         
2021-04-24T12:07:48Z Task Setup Building Task Directory                                         
2021-04-24T12:08:00Z Started Task started by client                                          
2021-04-24T12:09:17Z Restart Signaled healthcheck: check "66cf15a97e3a024dadbbfb595963ba3f" unhealthy 
2021-04-24T12:09:26Z Terminated Exit Code: 0                                                    
2021-04-24T12:09:26Z Restarting Task restarting in 1.10674283s                                  
2021-04-24T12:09:28Z Started Task started by client                                          
2021-04-24T12:10:46Z Restart Signaled healthcheck: check "66cf15a97e3a024dadbbfb595963ba3f" unhealthy 
2021-04-24T12:10:54Z Terminated Exit Code: 0                                                    
2021-04-24T12:10:54Z Restarting Task restarting in 1.032824943s                                 
2021-04-24T12:10:57Z Started Task started by client                                          
2021-04-24T12:12:14Z Restart Signaled healthcheck: check "66cf15a97e3a024dadbbfb595963ba3f" unhealthy 
2021-04-24T12:12:23Z Terminated Exit Code: 0                                                    
2021-04-24T12:12:23Z Not Restarting Exceeded allowed attempts 2 in interval 5m0s and mode is "fail" 
2021-04-24T12:12:23Z Alloc Unhealthy Unhealthy because of failed task                                
2021-04-24T12:12:23Z Killing Sent interrupt. Waiting 5s before force killing                 

Recent Logs
2021-04-24T12:09:29Z [info] Using strapi 3.6.0
2021-04-24T12:09:29Z [info] No project found at /srv/app. Creating a new strapi project
2021-04-24T12:09:29Z [info] Creating a new Strapi application at /srv/app.
2021-04-24T12:09:30Z [info] Creating a project from the database CLI arguments.
2021-04-24T12:09:31Z [info] Creating files.
2021-04-24T12:09:33Z [info] - Installing dependencies:
2021-04-24T12:09:34Z [info] Health check status changed to 'critical'
2021-04-24T12:10:46Z [info] Shutting down virtual machine
2021-04-24T12:10:46Z [info] Sending signal SIGINT to main child process w/ PID 503
2021-04-24T12:10:50Z [info] Health check status changed to 'passing'
2021-04-24T12:10:55Z [info] Starting instance
2021-04-24T12:10:55Z [info] Configuring virtual machine
2021-04-24T12:10:55Z [info] Pulling container image
2021-04-24T12:10:56Z [info] Unpacking image
2021-04-24T12:10:56Z [info] Preparing kernel init
2021-04-24T12:10:57Z [info] Configuring firecracker
2021-04-24T12:10:57Z [info] Starting virtual machine
2021-04-24T12:10:57Z [info] Starting init (commit: 665705e)...
2021-04-24T12:10:57Z [info] Running: `docker-entrypoint.sh strapi develop` as root
2021-04-24T12:10:57Z [info] 2021/04/24 12:10:57 listening on [fdaa:0:d1:a7b:a98:4afe:1213:2]:22 (DNS: [fdaa::3]:53)
2021-04-24T12:10:57Z [info] Using strapi 3.6.0
2021-04-24T12:10:57Z [info] No project found at /srv/app. Creating a new strapi project
2021-04-24T12:10:58Z [info] Creating a new Strapi application at /srv/app.
2021-04-24T12:10:59Z [info] Creating a project from the database CLI arguments.
2021-04-24T12:10:59Z [info] Creating files.
2021-04-24T12:11:02Z [info] - Installing dependencies:
2021-04-24T12:11:12Z [info] Health check status changed to 'critical'
2021-04-24T12:12:14Z [info] Shutting down virtual machine
2021-04-24T12:12:14Z [info] Sending signal SIGINT to main child process w/ PID 503
2021-04-24T12:12:20Z [info] Health check status changed to 'passing'
***v0 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v1 

Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/

```

What is strange is I am not getting any error from the strapi app itself telling me what has or has not failed, but I suspect a missing volume attachment. Instructions about the docker strapi-docker can be found at [GitHub - strapi/strapi-docker: Install and run your first Strapi project using Docker](https://github.com/strapi/strapi-docker),

---

<div class="post-metadata">

**Author:** ![jerome](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jerome/32/17_2.png) [@jerome](https://community.fly.io/u/jerome)\
**Post date:** [April 24, 2021, 1:40pm UTC](https://community.fly.io/t/deploying-a-strapi-image/1250/2 "2021-04-24T13:40:34Z")

</div>

Hey there!

We don’t support mounting volumes like Docker does at runtime. We support volumes, but they’re empty to begin with.

Your friend probably needs to create their own Dockerfile that inherits from `strapi/base` and `COPY` their files to `/srv/app`. Something like this: [strapi-docker/examples/custom at master · strapi/strapi-docker · GitHub](https://github.com/strapi/strapi-docker/tree/master/examples/custom) (the `.dockerignore` seems useful too, or else the build context will be much larger)

Looks like there are quite a few `DATABASE_` environment variables to set too. They’ll probably need to provision a PostgreSQL database somewhere. We offer that too!

```bash
flyctl postgres create
flyctl postgres attach -a your-app

```

I believe `strapi` supports `DATABASE_URL` which will be set automatically on your app when you `flyctl postgres attach`.

---

<div class="post-metadata">

**Author:** ![rugwiro](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/rugwiro/32/49239_2.png) [@rugwiro](https://community.fly.io/u/rugwiro)\
**Post date:** [April 24, 2021, 3:51pm UTC](https://community.fly.io/t/deploying-a-strapi-image/1250/3 "2021-04-24T15:51:15Z")

</div>

When you are deploying the image directly without creating a project strapi creates one using `strapi new`. And by default it expects you to indicate a sqlite file since it’s what it uses in dev mode. And it is probably trying to create one since in the base configuration there isn’t one. Does the vm allow writing to it’s filesystem? If not we would have to attach the file it wants as a volume.

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [April 24, 2021, 4:14pm UTC](https://community.fly.io/t/deploying-a-strapi-image/1250/4 "2021-04-24T16:14:21Z")

</div>

You can write to the filesystem but that data will vanish when you deploy or the VM restarts. You could use [litestream.io](http://litestream.io) to save sqlite files to s3 between runs with some extra work, otherwise attaching a volume is simplest.
