Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jlongster committed Apr 29, 2022
1 parent f9c0539 commit 3d01a76
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
user-files
server-files
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ log
supervise
bin/large-sync-data.txt
user-files
server-files
server-files
fly.toml
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ ENV NODE_ENV=production
ADD . .

RUN yarn install --production
RUN mkdir ./server-files
RUN mkdir ./user-files
RUN cp ./sql/default-account.sqlite ./server-files/account.sqlite

CMD ["yarn", "start"]
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,40 @@ You should deploy your server so it's always running. We recommend [fly.io](http

Next, [install the `flyctl`](https://fly.io/docs/flyctl/installing/) utility. Run `flyctl auth login` to sign into your account.

Open `fly.toml` and customize the app name on the first line of the file.
Copy `fly.template.toml` to `fly.toml`. Open `fly.toml` and customize the app name on the first line of the file.

Now, run `flyctl launch` from `actual-server`. You should have a running app now!

Whenever you want to update Actual, update the versions of `@actual-app/api` and `@actual-app/web` in `package.json` and run `flyctl deploy`.

**Note:** if you don't want to use fly, we still provide a `Dockerfile` to build the app so it should work anywhere that can compile a docker image.

### Persisting server data

One problem with the above setup is every time you deploy, it will wipe away all the data on the server. You'll need to bootstrap the instance again and upload your files.

Let's move the data somewhere that persists. With [fly.io](https://fly.io) we can create a [volume](https://fly.io/docs/reference/volumes/). Run this command:

```
flyctl volumes create actual_data
```

Now we need to tell Actual to use this volume. Add this in `fly.toml`:

```
[mounts]
source="actual_data"
destination="/data"
```

That's it! Actual will automatically check if the `/data` directory exists and use it automatically.

_You can also configure the data dir with the `ACTUAL_USER_FILES` environment variable._

## Configuring the server URL

The Actual app is totally separate from the server. In this project, they happen to both be served by the same server, but the app doesn't know where the server lives.

The server could live on a completely different domain. You might setup Actual so that the app and server are running in completely separate places.

Since Actual doesn't know what server to use, the first thing it does is asks you for the server URL. If you are running this project, simply click "Use this domain" and it will automatically fill it in with the current domain. This works because we are serving the app and server in the same place.
Since Actual doesn't know what server to use, the first thing it does is asks you for the server URL. If you are running this project, simply click "Use this domain" and it will automatically fill it in with the current domain. This works because we are serving the app and server in the same place.
39 changes: 39 additions & 0 deletions fly.template.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
app = "%NAME%"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]
PORT = "8080"

[experimental]
allowed_public_ports = []
auto_rollback = true

[[services]]
http_checks = []
internal_port = 5006
processes = ["app"]
protocol = "tcp"
script_checks = []

[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

[[services.ports]]
force_https = true
handlers = ["http"]
port = 80

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
6 changes: 5 additions & 1 deletion fly.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app = "%NAME%"
app = "actual-server"

kill_signal = "SIGINT"
kill_timeout = 5
Expand All @@ -11,6 +11,10 @@ processes = []
allowed_public_ports = []
auto_rollback = true

[mounts]
source="actual_data"
destination="/data"

[[services]]
http_checks = []
internal_port = 5006
Expand Down
4 changes: 3 additions & 1 deletion load-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ let config;
try {
config = require('./config');
} catch (e) {
let fs = require('fs');

config = {
mode: 'development',
port: 5006,
files: './user-files'
files: fs.existsSync('/data') ? '/data' : './user-files'
};
}

Expand Down
Binary file added sql/default-account.sqlite
Binary file not shown.

0 comments on commit 3d01a76

Please sign in to comment.