Deployment fails when setting up a Swift Vapor project

Hey,
I’ve tried following the Swift Vapor tutorial for setting up and deploying a Vapor project to fly.io: Vapor: Deploy → Fly

Everything worked except for the actual deployment:

fly deploy

==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-floral-resonance-8073 ready
==> Creating build context
--> Creating build context done
Error failed to fetch an image or build from source: error fetching docker server info: Get "http://[fdaa:1:b9ea:a7b:10b:a147:3e20:2]:2375/v1.41/info": context deadline exceeded

I’m totally new to deploying things (I’m just an iOS developer but I want to make a website with a Swift backend). I can’t really find anything helpful on Google.

I’d appreciate any help :slight_smile: Let me know if you need more information, I’m not sure what is needed to debug this.

Cheers
Dennis

Hey, are you running any VPN software? If so, try turning it off before deploying.

You can also try fly agent restart, then fly deploy, to see if that helps.

Otherwise, it’s possible your network has trouble with Wireguard traffic over UDP, which is what flyctl uses for connecting to your Fly.io network for deployment. Try fly wg websockets enable to see if that helps.

Hey, thanks for your reply :slight_smile:

I don’t have a VPN running. fly wg websockets enable did seem to help, it now starts deploying. However, after a few minutes, I get another error:

Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c swift build -c release --static-swift-stdlib]: exit code: 1

Interestingly, I just got an email saying

Hello! Your “fly-builder-floral-resonance-8073” application hosted on Fly.io crashed because it ran out of memory.

Is an empty Swift Vapor project too much already? :sweat_smile: According to the dashboard, it should have 4GB of memory. Does it need that much to deploy? Or might the Swift Vapor project be set up strangely (it’s the basic template project with no changes)?

That error does suggest the builder instance ran out of memory. I’m not familiar with Swift’s requirements, but you should be able to see memory usage trends on the Metrics section of the app dashboard.

Hm, the peak was around 3GB according to the graph

OK, that’s a lot - it probably got to 4GB in a quick burst before metrics could be scraped.

I just tried with a basic vapor template and got this:

3 24.45 Creating working copy for https://github.com/vapor/async-kit.git
#13 24.51 Working copy of https://github.com/vapor/async-kit.git resolved at 1.16.0
#13 26.31 error: unable to override package 'vapor' because its identity 'vapor' doesn't match override's identity (directory name) 'build'
#13 26.32 error: fatalError
------

Do you have a repo to try replicating the full build?

UPDATE: Just looked through some issues on the Vapor Github and found reports about high memory usage on linux. You could try introducing jemalloc to your Dockerfile as recommended in this comment: Possible memory "leak" under Linux · Issue #2493 · vapor/vapor · GitHub

That’s strange, I’m also using the basic vapor template. I haven’t changed anything. Here’s the repo:

I tried using jemalloc but it leads to the same error, unfortunately.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.