Skip to content

Commit

Permalink
demo project deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
tofran committed Mar 21, 2023
1 parent f022a6f commit f03028b
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 18 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/deploy-demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy Demo Project

on:
push:
# branches:
# - main
workflow_dispatch:

jobs:
build-and-deploy:
name: Build and deploy
if: |
(github.event_name == 'push' || github.event_name == 'workflow_dispatch')
&& github.ref == 'refs/heads/main'
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
working-directory: ./demo
run: flyctl -a ecto-sessions-demo deploy --remote-only"
if: github.ref == 'refs/heads/develop'
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
41 changes: 23 additions & 18 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 @@ -13,28 +17,29 @@ RUN mix local.hex --force && \
COPY mix.exs 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 add --no-cache \
openssl-dev \
libgcc \
libstdc++ \
ncurses-libs \
libcrypto3

# 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 f03028b

Please sign in to comment.