Skip to content

Commit

Permalink
Implement deployment with Fly.io and Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzhang committed Mar 11, 2022
1 parent 893d0d9 commit 54c1edc
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,17 @@ jobs:
- run: npm run check

- run: npm run build

deploy:
name: Deploy
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [rustfmt, rust, web]
steps:
- uses: actions/checkout@v2

- uses: superfly/flyctl-actions@master
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
with:
args: "deploy --remote-only"
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM rust:alpine as backend
WORKDIR /home/rust/src
RUN apk --no-cache add musl-dev openssl-dev protoc
RUN rustup component add rustfmt
COPY . .
RUN cargo build --release

FROM node:lts-alpine as frontend
WORKDIR /usr/src/app
COPY . .
RUN npm ci
RUN npm run build

FROM alpine:latest
WORKDIR /root
COPY --from=frontend /usr/src/app/build build
COPY --from=backend /home/rust/src/target/release/sshx-server .
CMD ["./sshx-server", "--host"]
27 changes: 27 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
app = "sshx"

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

[experimental]
allowed_public_ports = []
auto_rollback = true

[[services]]
internal_port = 8051
processes = ["app"]
protocol = "tcp"

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

[services.ports.tls_options]
alpn = ["h2"]

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

0 comments on commit 54c1edc

Please sign in to comment.