chore: prepare for prod
Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
parent
d369c75fa8
commit
5d05a87263
@ -45,6 +45,10 @@ USER nobody:nobody
|
||||
|
||||
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/ketbin ./
|
||||
|
||||
COPY --chown=nobody:nobody startup.sh startup.sh
|
||||
|
||||
RUN chmod +x /app/startup.sh
|
||||
|
||||
ENV HOME=/app
|
||||
|
||||
CMD ["bin/ketbin", "start"]
|
||||
CMD ["/app/startup.sh"]
|
10381
assets/package-lock.json
generated
Normal file
10381
assets/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
6655
assets/yarn.lock
6655
assets/yarn.lock
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@ use Mix.Config
|
||||
# which you should run after static files are built and
|
||||
# before starting your production server.
|
||||
config :ketbin, KetbinWeb.Endpoint,
|
||||
url: [host: "example.com", port: 80],
|
||||
url: [host: "dev.katb.in", port: 80],
|
||||
cache_static_manifest: "priv/static/cache_manifest.json"
|
||||
|
||||
# Do not print debug messages in production
|
||||
|
@ -12,9 +12,11 @@ database_url =
|
||||
"""
|
||||
|
||||
config :ketbin, Ketbin.Repo,
|
||||
# ssl: true,
|
||||
ssl: true,
|
||||
verify: :verify_peer,
|
||||
url: database_url,
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
||||
cacertfile: "priv/cert.pem"
|
||||
|
||||
secret_key_base =
|
||||
System.get_env("SECRET_KEY_BASE") ||
|
||||
@ -28,14 +30,14 @@ config :ketbin, KetbinWeb.Endpoint,
|
||||
port: String.to_integer(System.get_env("PORT") || "4000"),
|
||||
transport_options: [socket_opts: [:inet6]]
|
||||
],
|
||||
secret_key_base: secret_key_base
|
||||
secret_key_base: secret_key_base,
|
||||
server: true
|
||||
|
||||
# ## Using releases (Elixir v1.9+)
|
||||
#
|
||||
# If you are doing OTP releases, you need to instruct Phoenix
|
||||
# to start each relevant endpoint:
|
||||
#
|
||||
config :ketbin, KetbinWeb.Endpoint, server: true
|
||||
#
|
||||
# Then you can assemble a release by calling `mix release`.
|
||||
# See `mix help release` for more information.
|
||||
|
@ -29,6 +29,8 @@ defmodule KetbinWeb.PageController do
|
||||
# generate phonetic key
|
||||
id = Utils.generate_key()
|
||||
|
||||
IO.puts(conn.assigns[:current_user])
|
||||
|
||||
# check if content is a url
|
||||
is_url =
|
||||
Map.get(paste_params, "content")
|
||||
|
32
lib/release.ex
Normal file
32
lib/release.ex
Normal file
@ -0,0 +1,32 @@
|
||||
defmodule Ketbin.Release do
|
||||
@moduledoc """
|
||||
This module is used by the entrypoint to migrate the database
|
||||
"""
|
||||
|
||||
@app :ketbin
|
||||
|
||||
require Logger
|
||||
|
||||
def migrate do
|
||||
Application.ensure_all_started(@app)
|
||||
load_app()
|
||||
|
||||
for repo <- repos() do
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
|
||||
end
|
||||
end
|
||||
|
||||
def rollback(repo, version) do
|
||||
load_app()
|
||||
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
|
||||
end
|
||||
|
||||
defp repos do
|
||||
Application.fetch_env!(@app, :ecto_repos)
|
||||
end
|
||||
|
||||
defp load_app do
|
||||
Application.load(@app)
|
||||
end
|
||||
end
|
2
mix.exs
2
mix.exs
@ -20,7 +20,7 @@ defmodule Ketbin.MixProject do
|
||||
def application do
|
||||
[
|
||||
mod: {Ketbin.Application, []},
|
||||
extra_applications: [:logger, :runtime_tools]
|
||||
extra_applications: [:logger, :runtime_tools, :ssl],
|
||||
]
|
||||
end
|
||||
|
||||
|
25
priv/cert.pem
Normal file
25
priv/cert.pem
Normal file
@ -0,0 +1,25 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEQTCCAqmgAwIBAgIUKUbJkc6kHUPlOf0l1xQYzr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
YkT8qJ+odca6XpQmPjh1G5imefpqJ5xFxvPXYdlopKpWttx8R5z+YS84mq/ULG+x
|
||||
+uDxOyrX5euoihoPcYjotzDHV+LmaCIu0dybWuEtCvMSOKlicdOl9y2/93/I84WG
|
||||
VLHye4Qp5vIoXBEQ8FS5Furuh6ABFhp3LnKgJOeCn+u89sganuWf5JuCohK/9IfZ
|
||||
/VNd+DvggVxPDemX/9j1HzGdwQ/W4dD2GyBi6nT8TUrTMbV6S8FJC5Ba9Tovy9QN
|
||||
aO05pgq4LNlG9gecX45TzIPV2BsB6TYmvq/mbr5sGRQLgVlqiYC/KEH7cdnjN418
|
||||
gqBcwUlct0FiKHM1YWd0uXEEJh1yu14wnZmJDnr3Dkj2k7uyrUoMt9bDv5nnyocZ
|
||||
ub+CsnVPqBBHs4JOAw5atRxpGeEiSVZCJt6xpVHHl3vlW3pwFQ==
|
||||
-----END CERTIFICATE-----
|
38
startup.sh
Executable file
38
startup.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
log() {
|
||||
printf "[%s] %s\n" "$1" "$2"
|
||||
}
|
||||
|
||||
info() {
|
||||
log "INFO" "$1"
|
||||
}
|
||||
|
||||
error() {
|
||||
log "ERROR" "$1"
|
||||
}
|
||||
|
||||
migrate() {
|
||||
info 'Performing migrations with "Ketbin.Release.migrate()"'
|
||||
bin/ketbin eval "Ketbin.Release.migrate()"
|
||||
|
||||
LAST_EXIT=$?
|
||||
if [ $LAST_EXIT = 0 ]; then
|
||||
info 'Done performing migrations'
|
||||
else
|
||||
error "Unable to perform migrations, exit code $LAST_EXIT"
|
||||
exit $LAST_EXIT
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
info 'Starting the application'
|
||||
bin/ketbin start
|
||||
}
|
||||
|
||||
SLEEP_TIME=10
|
||||
info "Sleeping for $SLEEP_TIME seconds for all services to be up"
|
||||
sleep $SLEEP_TIME
|
||||
|
||||
migrate
|
||||
start
|
Loading…
Reference in New Issue
Block a user