Skip to content

Commit

Permalink
Elixir upgrade (#687)
Browse files Browse the repository at this point in the history
Upgrade elixir and use runtime.exs
  • Loading branch information
cheeseblubber committed Mar 26, 2021
1 parent 8c33ae1 commit e442da2
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 219 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/papercups.yml
Expand Up @@ -15,8 +15,8 @@ jobs:
- name: Initial setup
uses: erlef/setup-elixir@v1
with:
elixir-version: "1.10.4"
otp-version: "22.2.6"
elixir-version: "1.11.4"
otp-version: "23.0.3"

- name: Install dependencies
run: mix deps.get
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
@@ -1,4 +1,4 @@
erlang 23.0.3
elixir 1.10.4-otp-23
elixir 1.11.3-otp-23
nodejs 12.18.3
postgres 12.3
12 changes: 1 addition & 11 deletions Dockerfile
@@ -1,35 +1,25 @@
FROM elixir:1.10.4-alpine as builder
FROM elixir:1.11.3-alpine as builder

# build step
ARG MIX_ENV=prod
ARG NODE_ENV=production
ARG APP_VER=0.0.1
ARG REACT_APP_URL=localhost:3000
ARG USE_IP_V6=false
ARG REQUIRE_DB_SSL=false
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG BUCKET_NAME
ARG AWS_REGION
ARG REACT_APP_ADMIN_ACCOUNT_ID
ARG PAPERCUPS_STRIPE_SECRET
ARG REACT_APP_STRIPE_PUBLIC_KEY
ARG REACT_APP_EU_EDITION=false
ARG REACT_APP_FILE_UPLOADS_ENABLED

ENV REACT_APP_FILE_UPLOADS_ENABLED=1
ENV APP_VERSION=$APP_VER
ENV REACT_APP_URL=$REACT_APP_URL
ENV REQUIRE_DB_SSL=$REQUIRE_DB_SSL
ENV USE_IP_V6=$USE_IP_V6
ENV AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
ENV AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
ENV BUCKET_NAME=$BUCKET_NAME
ENV AWS_REGION=$AWS_REGION
ENV REACT_APP_ADMIN_ACCOUNT_ID=$REACT_APP_ADMIN_ACCOUNT_ID
ENV PAPERCUPS_STRIPE_SECRET=$PAPERCUPS_STRIPE_SECRET
ENV REACT_APP_STRIPE_PUBLIC_KEY=$REACT_APP_STRIPE_PUBLIC_KEY
ENV REACT_APP_EU_EDITION=$REACT_APP_EU_EDITION


RUN mkdir /app
Expand Down
63 changes: 0 additions & 63 deletions config/config.exs
@@ -1,22 +1,5 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.

# General application configuration
use Mix.Config

sentry_dsn = System.get_env("SENTRY_DSN")
mailgun_api_key = System.get_env("MAILGUN_API_KEY")
domain = System.get_env("DOMAIN")
site_id = System.get_env("CUSTOMER_IO_SITE_ID")
customerio_api_key = System.get_env("CUSTOMER_IO_API_KEY")
aws_key_id = System.get_env("AWS_ACCESS_KEY_ID")
aws_secret_key = System.get_env("AWS_SECRET_ACCESS_KEY")
bucket_name = System.get_env("BUCKET_NAME", "papercups-files")
region = System.get_env("AWS_REGION")

config :chat_api,
environment: Mix.env(),
ecto_repos: [ChatApi.Repo],
Expand All @@ -32,22 +15,11 @@ config :chat_api, ChatApiWeb.Endpoint,
pubsub_server: ChatApi.PubSub,
live_view: [signing_salt: "pRVXwt3k"]

config :logger,
backends: [:console, Sentry.LoggerBackend]

# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]

config :logger, Sentry.LoggerBackend,
# Also send warn messages
level: :warn,
# Send messages from Plug/Cowboy
excluded_domains: [],
# Send messages like `Logger.error("error")` to Sentry
capture_log_messages: true

# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason

Expand All @@ -69,14 +41,6 @@ config :chat_api, :phoenix_swagger,
]
}

# Configure Sentry
config :sentry,
dsn: sentry_dsn,
environment_name: Mix.env(),
included_environments: [:prod],
enable_source_code_context: true,
root_source_code_path: File.cwd!()

config :pow, Pow.Postgres.Store,
repo: ChatApi.Repo,
schema: ChatApi.Auth.PowSession
Expand All @@ -100,35 +64,8 @@ config :chat_api, Oban,
# {"0 * * * *", ChatApi.Workers.ArchiveStaleFreeTierConversations}
]

# Configure Mailgun
config :chat_api, ChatApi.Mailers.Mailgun,
adapter: Swoosh.Adapters.Mailgun,
api_key: mailgun_api_key,
domain: domain

config :chat_api, ChatApi.Mailers.Gmail, adapter: Swoosh.Adapters.Gmail

config :customerio,
site_id: site_id,
api_key: customerio_api_key

case System.get_env("PAPERCUPS_STRIPE_SECRET") do
"sk_" <> _rest = api_key ->
config :stripity_stripe, api_key: api_key

_ ->
nil
end

config :ex_aws,
access_key_id: aws_key_id,
secret_access_key: aws_secret_key,
s3: [
scheme: "https://",
host: bucket_name <> ".s3.amazonaws.com",
region: region
]

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
70 changes: 8 additions & 62 deletions config/prod.exs
@@ -1,17 +1,7 @@
use Mix.Config

# For production, don't forget to configure the url host
# to something meaningful, Phoenix uses this information
# when generating URLs.
#
# Note we also include the path to a cache manifest
# containing the digested version of static files. This
# manifest is generated by the `mix phx.digest` task,
# which you should run after static files are built and
# before starting your production server.
use Mix.Config

database_url = System.get_env("DATABASE_URL") || "ecto://postgres:postgres@localhost/chat_api"
database_url = System.get_env("DATABASE_URL") || "ecto://postgres:postgres@localhost/chat_api_dev"
pool_size = String.to_integer(System.get_env("POOL_SIZE") || "10")

require_db_ssl =
case System.get_env("REQUIRE_DB_SSL") do
Expand All @@ -20,57 +10,13 @@ require_db_ssl =
_ -> true
end

socket_options =
case System.get_env("USE_IP_V6") do
"true" -> [:inet6]
"false" -> [:inet]
_ -> [:inet]
end
# Do not print debug messages in production
config :logger, level: :info

# Heroku needs ssl to be set to true and it doesn't run
config :chat_api, ChatApi.Repo,
ssl: require_db_ssl,
url: database_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
socket_options: socket_options

secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
"dvPPvOjpgX2Wk8Y3ONrqWsgM9ZtU4sSrs4l/5CFD1sLm4H+CjLU+EidjNGuSz7bz"

config :chat_api, ChatApiWeb.Endpoint,
http: [
port: String.to_integer(System.get_env("PORT") || "4000"),
compress: true,
transport_options: [socket_opts: [:inet6]]
],
url: [scheme: "https", host: {:system, "BACKEND_URL"}, port: 443],
# FIXME: not sure the best way to handle this, but we want
# to allow our customers' websites to connect to our server
check_origin: false,
force_ssl: [rewrite_on: [:x_forwarded_proto]],
secret_key_base: secret_key_base

# Do not print debug messages in production
config :logger, level: :info

# The `cipher_suite` is set to `:strong` to support only the
# latest and more secure SSL ciphers. This means old browsers
# and clients may not be supported. You can set it to
# `:compatible` for wider support.
#
# `:keyfile` and `:certfile` expect an absolute path to the key
# and cert in disk or a relative path inside priv, for example
# "priv/ssl/server.key". For all supported SSL configuration
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
#
# We also recommend setting `force_ssl` in your endpoint, ensuring
# no data is ever sent via http, always redirecting to https:
#
# config :chat_api, ChatApiWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.

# Finally import the config/prod.secret.exs which loads secrets
# and configuration from environment variables.
# import_config "prod.secret.exs"
show_sensitive_data_on_connection_error: true,
socket_options: [:inet],
pool_size: pool_size
78 changes: 0 additions & 78 deletions config/releases.exs

This file was deleted.

0 comments on commit e442da2

Please sign in to comment.