Skip to content

Commit

Permalink
Merge pull request #4 from tofran/fly-deployment
Browse files Browse the repository at this point in the history
demo project deployment to fly
  • Loading branch information
tofran committed Mar 22, 2023
2 parents f022a6f + 82b2374 commit 4d0766d
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 21 deletions.
6 changes: 4 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.*
_build
deps
doc
doc

.env
*.env
24 changes: 24 additions & 0 deletions .github/workflows/deploy-demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Deploy Demo Project

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build-and-deploy:
name: Build and deploy
concurrency:
group: ${{ github.ref }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: superfly/flyctl-actions/setup-flyctl@master

- name: Deploy to fly
run: flyctl --config ./demo/fly.toml deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
42 changes: 23 additions & 19 deletions demo/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM hexpm/elixir:1.14.2-erlang-25.1-alpine-3.17.0 AS builder
ARG ELIXIR_VERSION=1.14.2
ARG ERLANG_VERSION=25.1
ARG ALPINE_VERSION=3.17.0

FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION} AS builder

WORKDIR /code

Expand All @@ -10,31 +14,31 @@ RUN apk update && \
RUN mix local.hex --force && \
mix local.rebar --force

COPY mix.exs mix.lock ./
COPY ./demo/mix.exs ./demo/mix.lock ./
RUN mix deps.get

COPY ./ ./
COPY ../ /ecto_sessions/
COPY ./demo/ ./
COPY ./ /ecto_sessions

# RUN mix do \
# compile, \
# release --path /release
RUN mix do \
compile, \
release --path /release

# FROM alpine:3.16.0 as runtime
FROM alpine:${ALPINE_VERSION} as runtime

# WORKDIR /app
WORKDIR /app

# RUN apk update && \
# apk add --no-cache \
# openssl-dev \
# libgcc \
# libstdc++ \
# ncurses-libs
RUN apk update && \
apk upgrade && \
apk add --no-cache \
libgcc \
libstdc++ \
ncurses-libs

# ENV MIX_ENV=${MIX_ENV}
ENV MIX_ENV=${MIX_ENV}

# COPY --from=builder /release/ ./
COPY --from=builder /release/ ./

# EXPOSE 4000
EXPOSE 4000

# CMD ["/app/bin/ecto_sessions_demo", "start"]
CMD ["/app/bin/ecto_sessions_demo", "start"]
File renamed without changes.
39 changes: 39 additions & 0 deletions demo/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
app = "ecto-sessions-demo"
kill_signal = "SIGTERM"
kill_timeout = 20
processes = []

[build]
dockerfile = "Dockerfile.prod"

[deploy]
release_command = "/app/bin/ecto_sessions_demo eval EctoSessionsDemo.ReleaseTasks.migrate"

[experimental]
auto_rollback = false
private_network = true

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

[services.concurrency]
hard_limit = 300
soft_limit = 200
type = "connections"

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

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

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

0 comments on commit 4d0766d

Please sign in to comment.