Compare commits
10 commits
11b7b6367c
...
3a1a329082
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a1a329082 | ||
|
|
5ef40852a6 | ||
|
|
e8b528e5f0 | ||
|
|
a3d521b078 | ||
|
|
094ccf73b5 | ||
|
|
49e5dfdc2f | ||
|
|
8795c4d00f | ||
|
|
58dd7e4fe0 | ||
|
|
b8ecd1201e | ||
|
|
657a4dfb6b |
4 changed files with 19 additions and 33 deletions
26
Dockerfile
26
Dockerfile
|
|
@ -25,34 +25,35 @@ RUN mix do deps.get, deps.compile
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
# Use Node.js to install assets
|
# Use Node.js to install assets
|
||||||
FROM node:14 AS node-build
|
FROM node:20 AS node-build
|
||||||
WORKDIR /app/assets
|
WORKDIR /app/assets
|
||||||
COPY assets/package.json assets/package-lock.json ./
|
COPY assets .
|
||||||
RUN npm install
|
RUN npm install -g pnpm
|
||||||
COPY assets/ ./
|
RUN pnpm install
|
||||||
RUN npm run deploy
|
|
||||||
|
|
||||||
# Switch back to our Elixir image to continue building
|
# Switch back to our Elixir image to continue building
|
||||||
FROM build AS app-build
|
FROM build AS app-build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=node-build /app/assets/build ./priv/static
|
|
||||||
RUN mix phx.digest
|
RUN mix phx.digest
|
||||||
|
|
||||||
# Copy our application source code
|
# Copy our application source code
|
||||||
|
COPY --from=node-build /app/assets assets
|
||||||
COPY lib lib
|
COPY lib lib
|
||||||
COPY priv priv
|
COPY priv priv
|
||||||
|
|
||||||
# Compile and build the application
|
# Compile and build the application
|
||||||
RUN mix do compile, phx.digest
|
RUN mix do compile, phx.digest, assets.deploy, ecto.create, ecto.migrate
|
||||||
|
|
||||||
# Create the release
|
# Create the release
|
||||||
|
RUN mix phx.gen.release
|
||||||
|
|
||||||
RUN mix release
|
RUN mix release
|
||||||
|
|
||||||
# ---- Application Stage ----
|
# ---- Application Stage ----
|
||||||
FROM debian:buster-slim AS app
|
FROM elixir:1.15.6-slim AS app
|
||||||
|
|
||||||
# Install runtime dependencies
|
# Install runtime dependencies
|
||||||
RUN apt-get update && apt-get install -y openssl libsqlite3-0 && apt-get clean
|
RUN apt-get update && apt-get install -y openssl libssl-dev libsqlite3-0 && apt-get clean
|
||||||
|
|
||||||
# Create and switch to the app user
|
# Create and switch to the app user
|
||||||
RUN useradd --create-home app
|
RUN useradd --create-home app
|
||||||
|
|
@ -60,8 +61,9 @@ USER app
|
||||||
WORKDIR /home/app
|
WORKDIR /home/app
|
||||||
|
|
||||||
# Copy over the build artifact from the previous step and create a symlink
|
# Copy over the build artifact from the previous step and create a symlink
|
||||||
COPY --from=build --chown=app:app /app/_build/prod/rel/ezcontainer_railway ./
|
COPY --from=app-build --chown=app:app /app/_build/prod/rel/ezcontainer_railway ./
|
||||||
RUN ln -s /home/app/ezcontainer_railway/bin/my_app /home/app/bin
|
COPY --from=app-build --chown=app:app /app/_build/prod/lib/ezcontainer_railway/priv/static priv/static
|
||||||
|
COPY --from=app-build --chown=app:app /app/db ./db
|
||||||
|
|
||||||
# Specify the entry point
|
# Specify the entry point
|
||||||
ENTRYPOINT ["bin/my_app", "start"]
|
ENTRYPOINT ["/home/app/bin/ezcontainer_railway", "start"]
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,11 @@ config :ezcontainer_railway, EzcontainerRailway.Repo,
|
||||||
# The watchers configuration can be used to run external
|
# The watchers configuration can be used to run external
|
||||||
# watchers to your application. For example, we can use it
|
# watchers to your application. For example, we can use it
|
||||||
# to bundle .js and .css sources.
|
# to bundle .js and .css sources.
|
||||||
|
port = String.to_integer(System.get_env("PORT") || "4000")
|
||||||
config :ezcontainer_railway, EzcontainerRailwayWeb.Endpoint,
|
config :ezcontainer_railway, EzcontainerRailwayWeb.Endpoint,
|
||||||
# Binding to loopback ipv4 address prevents access from other machines.
|
# Binding to loopback ipv4 address prevents access from other machines.
|
||||||
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
|
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
|
||||||
http: [ip: {127, 0, 0, 1}, port: 4000],
|
http: [ip: {0, 0, 0, 0}, port: port],
|
||||||
check_origin: false,
|
check_origin: false,
|
||||||
code_reloader: true,
|
code_reloader: true,
|
||||||
debug_errors: true,
|
debug_errors: true,
|
||||||
|
|
|
||||||
|
|
@ -16,25 +16,13 @@ import Config
|
||||||
#
|
#
|
||||||
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
|
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
|
||||||
# script that automatically sets the env var above.
|
# script that automatically sets the env var above.
|
||||||
if System.get_env("PHX_SERVER") do
|
config :ezcontainer_railway, EzcontainerRailwayWeb.Endpoint, server: true
|
||||||
config :ezcontainer_railway, EzcontainerRailwayWeb.Endpoint, server: true
|
|
||||||
end
|
|
||||||
|
|
||||||
if config_env() == :prod do
|
if config_env() == :prod do
|
||||||
database_url =
|
|
||||||
System.get_env("DATABASE_URL") ||
|
|
||||||
raise """
|
|
||||||
environment variable DATABASE_URL is missing.
|
|
||||||
For example: ecto://USER:PASS@HOST/DATABASE
|
|
||||||
"""
|
|
||||||
|
|
||||||
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
|
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
|
||||||
|
|
||||||
config :ezcontainer_railway, EzcontainerRailway.Repo,
|
config :ezcontainer_railway, EzcontainerRailway.Repo,
|
||||||
# ssl: true,
|
database: "./db/db_prod.sqlite3"
|
||||||
url: database_url,
|
|
||||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
|
||||||
socket_options: maybe_ipv6
|
|
||||||
|
|
||||||
# The secret key base is used to sign/encrypt cookies and other secrets.
|
# The secret key base is used to sign/encrypt cookies and other secrets.
|
||||||
# A default value is used in config/dev.exs and config/test.exs but you
|
# A default value is used in config/dev.exs and config/test.exs but you
|
||||||
|
|
@ -42,11 +30,7 @@ if config_env() == :prod do
|
||||||
# to check this value into version control, so we use an environment
|
# to check this value into version control, so we use an environment
|
||||||
# variable instead.
|
# variable instead.
|
||||||
secret_key_base =
|
secret_key_base =
|
||||||
System.get_env("SECRET_KEY_BASE") ||
|
System.get_env("SECRET_KEY_BASE") || "secret shhh"
|
||||||
raise """
|
|
||||||
environment variable SECRET_KEY_BASE is missing.
|
|
||||||
You can generate one by calling: mix phx.gen.secret
|
|
||||||
"""
|
|
||||||
|
|
||||||
host = System.get_env("PHX_HOST") || "example.com"
|
host = System.get_env("PHX_HOST") || "example.com"
|
||||||
port = String.to_integer(System.get_env("PORT") || "4000")
|
port = String.to_integer(System.get_env("PORT") || "4000")
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
defmodule EzcontainerRailway.GraphqlClient do
|
defmodule EzcontainerRailway.GraphqlClient do
|
||||||
@graphql_url "https://backboard.railway.app/graphql/v2"
|
@graphql_url "https://backboard.railway.app/graphql/v2"
|
||||||
@token "98237cc5-d503-4514-bb59-984d3403afe6"
|
|
||||||
|
|
||||||
def query(query, opts) when is_binary(query) and is_list(opts) do
|
def query(query, opts) when is_binary(query) and is_list(opts) do
|
||||||
body = %{
|
body = %{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue