Skip to content

Commit 54c1edc

Browse files
committedMar 11, 2022
Implement deployment with Fly.io and Docker
1 parent 893d0d9 commit 54c1edc

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed
 

‎.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.gitignore

‎.github/workflows/ci.yml

+14
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,17 @@ jobs:
4949
- run: npm run check
5050

5151
- run: npm run build
52+
53+
deploy:
54+
name: Deploy
55+
runs-on: ubuntu-latest
56+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
57+
needs: [rustfmt, rust, web]
58+
steps:
59+
- uses: actions/checkout@v2
60+
61+
- uses: superfly/flyctl-actions@master
62+
env:
63+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
64+
with:
65+
args: "deploy --remote-only"

‎Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM rust:alpine as backend
2+
WORKDIR /home/rust/src
3+
RUN apk --no-cache add musl-dev openssl-dev protoc
4+
RUN rustup component add rustfmt
5+
COPY . .
6+
RUN cargo build --release
7+
8+
FROM node:lts-alpine as frontend
9+
WORKDIR /usr/src/app
10+
COPY . .
11+
RUN npm ci
12+
RUN npm run build
13+
14+
FROM alpine:latest
15+
WORKDIR /root
16+
COPY --from=frontend /usr/src/app/build build
17+
COPY --from=backend /home/rust/src/target/release/sshx-server .
18+
CMD ["./sshx-server", "--host"]

‎fly.toml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
app = "sshx"
2+
3+
kill_signal = "SIGINT"
4+
kill_timeout = 5
5+
processes = []
6+
7+
[experimental]
8+
allowed_public_ports = []
9+
auto_rollback = true
10+
11+
[[services]]
12+
internal_port = 8051
13+
processes = ["app"]
14+
protocol = "tcp"
15+
16+
[[services.ports]]
17+
handlers = ["tls"]
18+
port = 443
19+
20+
[services.ports.tls_options]
21+
alpn = ["h2"]
22+
23+
[[services.tcp_checks]]
24+
grace_period = "1s"
25+
interval = "15s"
26+
restart_limit = 0
27+
timeout = "2s"

0 commit comments

Comments
 (0)