Merge pull request #2 from CloudFire-LLC/mix-release

Rename cloudfire app to cf_phx; Start Dockerfile work
This commit is contained in:
Jamil
2020-04-22 22:27:58 -07:00
committed by GitHub
99 changed files with 286 additions and 191 deletions

9
.dockerignore Normal file
View File

@@ -0,0 +1,9 @@
_build/
deps/
.git/
.gitignore/
Dockerfile
Makefile
README*
LICENSE
test/

16
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
name: Deploy
on:
release: created
jobs:
build-image:
runs-on: ubuntu:18.04
steps:
- uses: actions/checkout@v2
- name: Build Docker Image
run: |
docker build -t cloudfirellc/cloudfire:latest .
- name: Push Docker Image
run: |
docker push cloudfirellc/cloudfire:latest

View File

@@ -1,12 +1,12 @@
# Unit test
name: CI
on:
- push
- pull_request
- release
jobs:
test:
unit-test:
runs-on: ubuntu-18.04
env:
MIX_ENV: test

3
.gitignore vendored
View File

@@ -25,9 +25,6 @@ erl_crash.dump
# If NPM crashes, it generates a log, let's ignore it too.
npm-debug.log
# Assets should be served by a CDN, not tracked in version control
/assets/static
# The directory NPM downloads your dependencies sources to.
/assets/node_modules/

53
Dockerfile Normal file
View File

@@ -0,0 +1,53 @@
FROM elixir:1.10.2-alpine AS builder
MAINTAINER docker@cloudfire.network
ARG MIX_ENV=prod
ARG PHOENIX_DIR=./apps/cloudfire
# These are used only for building and won't matter later on
# ENV DATABASE_URL=ecto://dummy:dummy@dummy/dummy
# ENV SECRET_KEY_BASE=dummy
# Install dependencies
RUN apk add npm
WORKDIR /app
RUN mix do local.hex --force, local.rebar --force
COPY config/ .
COPY mix.exs ./
COPY mix.* ./
COPY apps/cf_phx/mix.exs ./apps/cf_phx/
COPY apps/system_engine/mix.exs ./apps/system_engine/
RUN mix do deps.get --only $MIX_ENV, deps.compile
COPY . .
RUN npm install --prefix $PHOENIX_DIR/assets
RUN npm run deploy --prefix $PHOENIX_DIR/assets
RUN mix phx.digest
RUN mix release bundled
# The built application is now contained in _build/
# This is what the builder image is based on
FROM alpine:3.11
RUN apk add --no-cache \
ncurses-dev \
openssl-dev
EXPOSE 4000
ENV PORT=4000 \
MIX_ENV=prod \
SHELL=/bin/bash
WORKDIR /app
COPY --from=builder /app/_build/prod/rel/bundled .
CMD ["bin/bundled", "start"]

3
apps/cf_phx/README.md Normal file
View File

@@ -0,0 +1,3 @@
# CfPhx

View File

@@ -6,8 +6,8 @@
"watch": "webpack --mode development --watch"
},
"dependencies": {
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html"
"phoenix": "file:../../../deps/phoenix",
"phoenix_html": "file:../../../deps/phoenix_html"
},
"devDependencies": {
"@babel/core": "^7.9.0",

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="100pt" height="100pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<g fill-rule="evenodd">
<path d="m34.305 41.426c-3.8828-0.97266-21.035-6.1484-34.305-11.652-0.32422 0.32422 1.9414 6.7969 10.355 9.707 5.8242 1.6172 18.77 4.5312 24.594 5.8242-4.207-0.32422-18.121-2.2656-33.332-5.5-0.32422 0.32422 2.2656 6.1484 10.355 7.4453 5.1797 0.64844 17.152 1.6172 23.301 1.9414-3.2344 0.32422-16.504 0.97266-26.215 0.32422 0 0.32422 3.8828 4.8555 9.707 4.5312 4.8555 0 16.828-0.97266 21.359-1.293-2.9141 0.64844-17.801 3.5586-25.566 4.207 0 0.32422 3.5586 3.2344 8.0898 2.5898 3.8828-0.64844 15.859-3.5586 19.094-4.5312-2.2656 1.293-11.973 4.207-20.387 6.4727 0 0.32422 3.5586 2.5898 7.4453 1.293 2.9141-0.97266 9.707-3.5586 13.27-4.8555-2.2656 1.293-3.5586 2.2656-11.004 5.5 3.8828 6.7969 9.3867 13.594 19.094 18.121 9.3867-4.5312 15.211-11.328 18.77-18.121-7.4453-3.2344-8.7383-4.207-11.004-5.5 3.5586 1.293 10.355 3.8828 13.27 4.8555 4.207 1.293 7.4453-0.97266 7.4453-1.293-8.0898-2.2656-18.121-5.1797-20.387-6.4727 3.5586 0.97266 15.211 3.8828 19.418 4.5312 4.5312 0.64844 7.7656-2.2656 7.7656-2.5898-7.4453-0.64844-22.652-3.5586-25.242-4.207 4.207 0.32422 16.18 1.293 21.035 1.293 5.8242 0.32422 9.707-4.207 9.707-4.5312-9.707 0.64844-22.977 0-26.215-0.32422 6.1484-0.32422 18.121-1.293 23.301-1.9414 8.0898-1.293 10.68-7.1211 10.68-7.4453-15.211 3.2344-29.449 5.1797-33.656 5.5 5.8242-1.293 19.094-4.207 24.594-5.8242 8.4141-2.9141 10.68-9.3867 10.355-9.707-13.27 5.5-30.098 10.68-34.305 11.652 6.7969-2.9141 22.977-10.355 27.184-13.27 4.8555-3.5586 6.4727-9.707 5.8242-9.707-16.504 10.031-33.98 16.828-38.836 19.742-5.1797 2.9141-1.293 6.1484-1.6172 8.4141-0.97266 3.5586-5.1797 5.8242-8.0898 7.1211-2.9141-1.293-7.4453-3.5586-8.0898-7.1211-0.64844-2.2656 3.2344-5.5-1.9414-8.4141-4.8555-2.9141-22.008-9.707-38.836-19.742-0.64844 0 0.97266 6.1484 5.8242 9.707 4.207 2.9141 20.387 10.355 27.184 13.27z"/>
<path d="m24.273 26.215h51.781v3.5586c-7.4453 1.9414-16.504 3.2344-25.891 3.2344-9.707 0-18.77-1.293-25.891-3.2344z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,5 @@
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /

View File

@@ -1,6 +1,6 @@
defmodule Cloudfire do
defmodule CfPhx do
@moduledoc """
Cloudfire keeps the contexts that define your domain
CfPhx keeps the contexts that define your domain
and business logic.
Contexts are also responsible for managing your data, regardless

View File

@@ -1,4 +1,4 @@
defmodule Cloudfire.Application do
defmodule CfPhx.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
@@ -9,23 +9,23 @@ defmodule Cloudfire.Application do
# List all child processes to be supervised
children = [
# Start the Ecto repository
Cloudfire.Repo,
CfPhx.Repo,
# Start the endpoint when the application starts
CloudfireWeb.Endpoint
# Starts a worker by calling: Cloudfire.Worker.start_link(arg)
# {Cloudfire.Worker, arg},
CfPhxWeb.Endpoint
# Starts a worker by calling: CfPhx.Worker.start_link(arg)
# {CfPhx.Worker, arg},
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Cloudfire.Supervisor]
opts = [strategy: :one_for_one, name: CfPhx.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
def config_change(changed, _new, removed) do
CloudfireWeb.Endpoint.config_change(changed, removed)
CfPhxWeb.Endpoint.config_change(changed, removed)
:ok
end
end

View File

@@ -1,12 +1,12 @@
defmodule Cloudfire.Devices do
defmodule CfPhx.Devices do
@moduledoc """
The Devices context.
"""
import Ecto.Query, warn: false
alias Cloudfire.Repo
alias CfPhx.Repo
alias Cloudfire.Devices.Device
alias CfPhx.Devices.Device
@doc """
Returns the list of devices.

View File

@@ -1,4 +1,4 @@
defmodule Cloudfire.Devices.Device do
defmodule CfPhx.Devices.Device do
use Ecto.Schema
import Ecto.Changeset
@@ -8,7 +8,7 @@ defmodule Cloudfire.Devices.Device do
field :verified_at, :utc_datetime
field :user_id, :id
has_many :firewall_rules, Cloudfire.FirewallRules.FirewallRule
has_many :firewall_rules, CfPhx.FirewallRules.FirewallRule
timestamps()
end

View File

@@ -1,12 +1,12 @@
defmodule Cloudfire.FirewallRules do
defmodule CfPhx.FirewallRules do
@moduledoc """
The FirewallRules context.
"""
import Ecto.Query, warn: false
alias Cloudfire.Repo
alias CfPhx.Repo
alias Cloudfire.FirewallRules.FirewallRule
alias CfPhx.FirewallRules.FirewallRule
@doc """
Returns the list of firewall_rules.

View File

@@ -1,4 +1,4 @@
defmodule Cloudfire.FirewallRules.FirewallRule do
defmodule CfPhx.FirewallRules.FirewallRule do
use Ecto.Schema
import Ecto.Changeset
@@ -8,7 +8,7 @@ defmodule Cloudfire.FirewallRules.FirewallRule do
field :port, :string
field :protocol, :string
belongs_to :device, Cloudfire.Devices.Device
belongs_to :device, CfPhx.Devices.Device
timestamps()
end

View File

@@ -1,5 +1,5 @@
defmodule Cloudfire.Repo do
defmodule CfPhx.Repo do
use Ecto.Repo,
otp_app: :cloudfire,
otp_app: :cf_phx,
adapter: Ecto.Adapters.Postgres
end

View File

@@ -1,4 +1,4 @@
defmodule Cloudfire.User do
defmodule CfPhx.User do
use Ecto.Schema
import Ecto.Changeset

View File

@@ -1,12 +1,12 @@
defmodule CloudfireWeb do
defmodule CfPhxWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
use CloudfireWeb, :controller
use CloudfireWeb, :view
use CfPhxWeb, :controller
use CfPhxWeb, :view
The definitions below will be executed for every view,
controller, etc, so keep them short and clean, focused
@@ -19,19 +19,19 @@ defmodule CloudfireWeb do
def controller do
quote do
use Phoenix.Controller, namespace: CloudfireWeb
use Phoenix.Controller, namespace: CfPhxWeb
import Plug.Conn
import CloudfireWeb.Gettext
alias CloudfireWeb.Router.Helpers, as: Routes
import CfPhxWeb.Gettext
alias CfPhxWeb.Router.Helpers, as: Routes
end
end
def view do
quote do
use Phoenix.View,
root: "lib/cloudfire_web/templates",
namespace: CloudfireWeb
root: "lib/cf_phx_web/templates",
namespace: CfPhxWeb
# Import convenience functions from controllers
import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1]
@@ -39,9 +39,9 @@ defmodule CloudfireWeb do
# Use all HTML functionality (forms, tags, etc)
use Phoenix.HTML
import CloudfireWeb.ErrorHelpers
import CloudfireWeb.Gettext
alias CloudfireWeb.Router.Helpers, as: Routes
import CfPhxWeb.ErrorHelpers
import CfPhxWeb.Gettext
alias CfPhxWeb.Router.Helpers, as: Routes
end
end
@@ -56,7 +56,7 @@ defmodule CloudfireWeb do
def channel do
quote do
use Phoenix.Channel
import CloudfireWeb.Gettext
import CfPhxWeb.Gettext
end
end

View File

@@ -1,8 +1,8 @@
defmodule CloudfireWeb.UserSocket do
defmodule CfPhxWeb.UserSocket do
use Phoenix.Socket
## Channels
# channel "room:*", CloudfireWeb.RoomChannel
# channel "room:*", CfPhxWeb.RoomChannel
# Socket params are passed from the client and can
# be used to verify and authenticate a user. After
@@ -26,7 +26,7 @@ defmodule CloudfireWeb.UserSocket do
# Would allow you to broadcast a "disconnect" event and terminate
# all active sockets and channels for a given user:
#
# CloudfireWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
# CfPhxWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
#
# Returning `nil` makes this socket anonymous.
def id(_socket), do: nil

View File

@@ -1,10 +1,10 @@
defmodule CloudfireWeb.DeviceController do
use CloudfireWeb, :controller
defmodule CfPhxWeb.DeviceController do
use CfPhxWeb, :controller
alias Cloudfire.Devices
alias Cloudfire.Devices.Device
alias CfPhx.Devices
alias CfPhx.Devices.Device
plug CloudfireWeb.Plugs.Authenticator
plug CfPhxWeb.Plugs.Authenticator
def index(conn, _params) do
devices = Devices.list_devices()

View File

@@ -1,11 +1,11 @@
defmodule CloudfireWeb.FirewallRuleController do
use CloudfireWeb, :controller
defmodule CfPhxWeb.FirewallRuleController do
use CfPhxWeb, :controller
alias Cloudfire.FirewallRules
alias Cloudfire.FirewallRules.FirewallRule
alias Cloudfire.Devices
alias CfPhx.FirewallRules
alias CfPhx.FirewallRules.FirewallRule
alias CfPhx.Devices
plug CloudfireWeb.Plugs.Authenticator
plug CfPhxWeb.Plugs.Authenticator
def index(conn, %{"device_id" => device_id}) do
device = Devices.get_device!(device_id)

View File

@@ -0,0 +1,7 @@
defmodule CfPhxWeb.PageController do
use CfPhxWeb, :controller
def index(conn, _params) do
render(conn, "index.html")
end
end

View File

@@ -1,12 +1,12 @@
defmodule CloudfireWeb.UserController do
defmodule CfPhxWeb.UserController do
@moduledoc """
Implements the CRUD for a User
"""
use CloudfireWeb, :controller
alias Cloudfire.{Repo, User}
use CfPhxWeb, :controller
alias CfPhx.{Repo, User}
plug CloudfireWeb.Plugs.Authenticator when action in [:show, :edit, :update, :delete]
plug CfPhxWeb.Plugs.Authenticator when action in [:show, :edit, :update, :delete]
# GET /users/new
def new(conn, _params) do

View File

@@ -1,16 +1,16 @@
defmodule CloudfireWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :cloudfire
defmodule CfPhxWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :cf_phx
# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
@session_options [
store: :cookie,
key: "_cloudfire_key",
key: "_cf_phx_key",
signing_salt: "Z9eq8iof"
]
socket "/socket", CloudfireWeb.UserSocket,
socket "/socket", CfPhxWeb.UserSocket,
websocket: true,
longpoll: false
@@ -20,7 +20,7 @@ defmodule CloudfireWeb.Endpoint do
# when deploying your static files in production.
plug Plug.Static,
at: "/",
from: :cloudfire,
from: :cf_phx,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
@@ -43,5 +43,5 @@ defmodule CloudfireWeb.Endpoint do
plug Plug.MethodOverride
plug Plug.Head
plug Plug.Session, @session_options
plug CloudfireWeb.Router
plug CfPhxWeb.Router
end

View File

@@ -1,11 +1,11 @@
defmodule CloudfireWeb.Gettext do
defmodule CfPhxWeb.Gettext do
@moduledoc """
A module providing Internationalization with a gettext-based API.
By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example:
import CloudfireWeb.Gettext
import CfPhxWeb.Gettext
# Simple translation
gettext("Here is the string to translate")
@@ -20,5 +20,5 @@ defmodule CloudfireWeb.Gettext do
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
use Gettext, otp_app: :cloudfire
use Gettext, otp_app: :cf_phx
end

View File

@@ -1,10 +1,10 @@
defmodule CloudfireWeb.Plugs.Authenticator do
defmodule CfPhxWeb.Plugs.Authenticator do
@moduledoc """
Loads the user's session from cookie
"""
import Plug.Conn
alias Cloudfire.User
alias CfPhx.User
def init(default), do: default

View File

@@ -1,5 +1,5 @@
defmodule CloudfireWeb.Router do
use CloudfireWeb, :router
defmodule CfPhxWeb.Router do
use CfPhxWeb, :router
pipeline :browser do
plug :accepts, ["html"]
@@ -13,7 +13,7 @@ defmodule CloudfireWeb.Router do
plug :accepts, ["json"]
end
scope "/", CloudfireWeb do
scope "/", CfPhxWeb do
pipe_through :browser
get "/", PageController, :index
@@ -27,7 +27,7 @@ defmodule CloudfireWeb.Router do
end
# Other scopes may use custom stacks.
# scope "/api", CloudfireWeb do
# scope "/api", CfPhxWeb do
# pipe_through :api
# end
end

View File

@@ -16,7 +16,7 @@
<li><a href="<%= Routes.device_path(@conn, :index) %>">Devices</a></li>
</ul>
</nav>
<a href="<%= CloudfireWeb.Endpoint.url() %>" class="cf-logo">
<a href="<%= CfPhxWeb.Endpoint.url() %>" class="cf-logo">
<img src="<%= Routes.static_path(@conn, "/images/logo.svg") %>" alt="Cloudfire Logo"/>
</a>
</section>

View File

@@ -0,0 +1,3 @@
defmodule CfPhxWeb.DeviceView do
use CfPhxWeb, :view
end

View File

@@ -1,4 +1,4 @@
defmodule CloudfireWeb.ErrorHelpers do
defmodule CfPhxWeb.ErrorHelpers do
@moduledoc """
Conveniences for translating and building error messages.
"""
@@ -36,9 +36,9 @@ defmodule CloudfireWeb.ErrorHelpers do
# should be written to the errors.po file. The :count option is
# set by Ecto and indicates we should also apply plural rules.
if count = opts[:count] do
Gettext.dngettext(CloudfireWeb.Gettext, "errors", msg, msg, count, opts)
Gettext.dngettext(CfPhxWeb.Gettext, "errors", msg, msg, count, opts)
else
Gettext.dgettext(CloudfireWeb.Gettext, "errors", msg, opts)
Gettext.dgettext(CfPhxWeb.Gettext, "errors", msg, opts)
end
end
end

View File

@@ -1,5 +1,5 @@
defmodule CloudfireWeb.ErrorView do
use CloudfireWeb, :view
defmodule CfPhxWeb.ErrorView do
use CfPhxWeb, :view
# If you want to customize a particular status code
# for a certain format, you may uncomment below.

View File

@@ -0,0 +1,3 @@
defmodule CfPhxWeb.FirewallRuleView do
use CfPhxWeb, :view
end

View File

@@ -0,0 +1,3 @@
defmodule CfPhxWeb.LayoutView do
use CfPhxWeb, :view
end

View File

@@ -0,0 +1,3 @@
defmodule CfPhxWeb.PageView do
use CfPhxWeb, :view
end

View File

@@ -0,0 +1,3 @@
defmodule CfPhxWeb.UserView do
use CfPhxWeb, :view
end

View File

@@ -1,9 +1,9 @@
defmodule Cloudfire.MixProject do
defmodule CfPhx.MixProject do
use Mix.Project
def project do
[
app: :cloudfire,
app: :cf_phx,
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
@@ -23,7 +23,7 @@ defmodule Cloudfire.MixProject do
# Type `mix help compile.app` for more information.
def application do
[
mod: {Cloudfire.Application, []},
mod: {CfPhx.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end

View File

@@ -1,4 +1,4 @@
defmodule Cloudfire.Repo.Migrations.CreateUsers do
defmodule CfPhx.Repo.Migrations.CreateUsers do
use Ecto.Migration
def change do

View File

@@ -1,4 +1,4 @@
defmodule Cloudfire.Repo.Migrations.CreateDevices do
defmodule CfPhx.Repo.Migrations.CreateDevices do
use Ecto.Migration
def change do

View File

@@ -1,4 +1,4 @@
defmodule Cloudfire.Repo.Migrations.CreateFirewallRules do
defmodule CfPhx.Repo.Migrations.CreateFirewallRules do
use Ecto.Migration
def change do

View File

@@ -5,7 +5,7 @@
# Inside the script, you can read and write to any of your
# repositories directly:
#
# Cloudfire.Repo.insert!(%Cloudfire.SomeSchema{})
# CfPhx.Repo.insert!(%CfPhx.SomeSchema{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.

View File

@@ -0,0 +1,6 @@
defmodule CfPhx.DevicesTest do
use CfPhx.DataCase
describe "devices" do
end
end

View File

@@ -0,0 +1,6 @@
defmodule CfPhx.FirewallRulesTest do
use CfPhx.DataCase
describe "firewall_rules" do
end
end

View File

@@ -1,7 +1,7 @@
defmodule CloudfireWeb.DeviceControllerTest do
use CloudfireWeb.ConnCase
defmodule CfPhxWeb.DeviceControllerTest do
use CfPhxWeb.ConnCase
alias Cloudfire.Devices
alias CfPhx.Devices
@create_attrs %{name: "some name"}
@update_attrs %{name: "some updated name"}

View File

@@ -1,5 +1,5 @@
defmodule CloudfireWeb.FirewallRuleControllerTest do
use CloudfireWeb.ConnCase
defmodule CfPhxWeb.FirewallRuleControllerTest do
use CfPhxWeb.ConnCase
describe "index" do
end

View File

@@ -1,5 +1,5 @@
defmodule CloudfireWeb.PageControllerTest do
use CloudfireWeb.ConnCase
defmodule CfPhxWeb.PageControllerTest do
use CfPhxWeb.ConnCase
test "GET /", %{conn: conn} do
conn = get(conn, "/")

View File

@@ -0,0 +1,14 @@
defmodule CfPhxWeb.ErrorViewTest do
use CfPhxWeb.ConnCase, async: true
# Bring render/3 and render_to_string/3 for testing custom views
import Phoenix.View
test "renders 404.html" do
assert render_to_string(CfPhxWeb.ErrorView, "404.html", []) == "Not Found"
end
test "renders 500.html" do
assert render_to_string(CfPhxWeb.ErrorView, "500.html", []) == "Internal Server Error"
end
end

View File

@@ -1,5 +1,5 @@
defmodule CloudfireWeb.LayoutViewTest do
use CloudfireWeb.ConnCase, async: true
defmodule CfPhxWeb.LayoutViewTest do
use CfPhxWeb.ConnCase, async: true
# When testing helpers, you may want to import Phoenix.HTML and
# use functions such as safe_to_string() to convert the helper

View File

@@ -0,0 +1,3 @@
defmodule CfPhxWeb.PageViewTest do
use CfPhxWeb.ConnCase, async: true
end

View File

@@ -1,4 +1,4 @@
defmodule CloudfireWeb.ChannelCase do
defmodule CfPhxWeb.ChannelCase do
@moduledoc """
This module defines the test case to be used by
channel tests.
@@ -11,7 +11,7 @@ defmodule CloudfireWeb.ChannelCase do
we enable the SQL sandbox, so changes done to the database
are reverted at the end of every test. If you are using
PostgreSQL, you can even run database tests asynchronously
by setting `use CloudfireWeb.ChannelCase, async: true`, although
by setting `use CfPhxWeb.ChannelCase, async: true`, although
this option is not recommended for other databases.
"""
@@ -23,15 +23,15 @@ defmodule CloudfireWeb.ChannelCase do
use Phoenix.ChannelTest
# The default endpoint for testing
@endpoint CloudfireWeb.Endpoint
@endpoint CfPhxWeb.Endpoint
end
end
setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Cloudfire.Repo)
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfPhx.Repo)
unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(Cloudfire.Repo, {:shared, self()})
Ecto.Adapters.SQL.Sandbox.mode(CfPhx.Repo, {:shared, self()})
end
:ok

View File

@@ -1,4 +1,4 @@
defmodule CloudfireWeb.ConnCase do
defmodule CfPhxWeb.ConnCase do
@moduledoc """
This module defines the test case to be used by
tests that require setting up a connection.
@@ -11,7 +11,7 @@ defmodule CloudfireWeb.ConnCase do
we enable the SQL sandbox, so changes done to the database
are reverted at the end of every test. If you are using
PostgreSQL, you can even run database tests asynchronously
by setting `use CloudfireWeb.ConnCase, async: true`, although
by setting `use CfPhxWeb.ConnCase, async: true`, although
this option is not recommended for other databases.
"""
@@ -21,18 +21,18 @@ defmodule CloudfireWeb.ConnCase do
quote do
# Import conveniences for testing with connections
use Phoenix.ConnTest
alias CloudfireWeb.Router.Helpers, as: Routes
alias CfPhxWeb.Router.Helpers, as: Routes
# The default endpoint for testing
@endpoint CloudfireWeb.Endpoint
@endpoint CfPhxWeb.Endpoint
end
end
setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Cloudfire.Repo)
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfPhx.Repo)
unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(Cloudfire.Repo, {:shared, self()})
Ecto.Adapters.SQL.Sandbox.mode(CfPhx.Repo, {:shared, self()})
end
{:ok, conn: Phoenix.ConnTest.build_conn()}

View File

@@ -1,4 +1,4 @@
defmodule Cloudfire.DataCase do
defmodule CfPhx.DataCase do
@moduledoc """
This module defines the setup for tests requiring
access to the application's data layer.
@@ -10,7 +10,7 @@ defmodule Cloudfire.DataCase do
we enable the SQL sandbox, so changes done to the database
are reverted at the end of every test. If you are using
PostgreSQL, you can even run database tests asynchronously
by setting `use Cloudfire.DataCase, async: true`, although
by setting `use CfPhx.DataCase, async: true`, although
this option is not recommended for other databases.
"""
@@ -18,20 +18,20 @@ defmodule Cloudfire.DataCase do
using do
quote do
alias Cloudfire.Repo
alias CfPhx.Repo
import Ecto
import Ecto.Changeset
import Ecto.Query
import Cloudfire.DataCase
import CfPhx.DataCase
end
end
setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Cloudfire.Repo)
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfPhx.Repo)
unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(Cloudfire.Repo, {:shared, self()})
Ecto.Adapters.SQL.Sandbox.mode(CfPhx.Repo, {:shared, self()})
end
:ok

View File

@@ -0,0 +1,2 @@
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(CfPhx.Repo, :manual)

View File

@@ -1,3 +0,0 @@
# Cloudfire

View File

@@ -1,7 +0,0 @@
defmodule CloudfireWeb.PageController do
use CloudfireWeb, :controller
def index(conn, _params) do
render(conn, "index.html")
end
end

View File

@@ -1,3 +0,0 @@
defmodule CloudfireWeb.DeviceView do
use CloudfireWeb, :view
end

View File

@@ -1,3 +0,0 @@
defmodule CloudfireWeb.FirewallRuleView do
use CloudfireWeb, :view
end

View File

@@ -1,3 +0,0 @@
defmodule CloudfireWeb.LayoutView do
use CloudfireWeb, :view
end

View File

@@ -1,3 +0,0 @@
defmodule CloudfireWeb.PageView do
use CloudfireWeb, :view
end

View File

@@ -1,3 +0,0 @@
defmodule CloudfireWeb.UserView do
use CloudfireWeb, :view
end

View File

@@ -1,6 +0,0 @@
defmodule Cloudfire.DevicesTest do
use Cloudfire.DataCase
describe "devices" do
end
end

View File

@@ -1,6 +0,0 @@
defmodule Cloudfire.FirewallRulesTest do
use Cloudfire.DataCase
describe "firewall_rules" do
end
end

View File

@@ -1,14 +0,0 @@
defmodule CloudfireWeb.ErrorViewTest do
use CloudfireWeb.ConnCase, async: true
# Bring render/3 and render_to_string/3 for testing custom views
import Phoenix.View
test "renders 404.html" do
assert render_to_string(CloudfireWeb.ErrorView, "404.html", []) == "Not Found"
end
test "renders 500.html" do
assert render_to_string(CloudfireWeb.ErrorView, "500.html", []) == "Internal Server Error"
end
end

View File

@@ -1,3 +0,0 @@
defmodule CloudfireWeb.PageViewTest do
use CloudfireWeb.ConnCase, async: true
end

View File

@@ -1,2 +0,0 @@
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(Cloudfire.Repo, :manual)

View File

@@ -5,17 +5,17 @@
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `firewall_daemon` to your list of dependencies in `mix.exs`:
by adding `system_engine` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:firewall_daemon, "~> 0.1.0"}
{:system_engine, "~> 0.1.0"}
]
end
```
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/firewall_daemon](https://hexdocs.pm/firewall_daemon).
be found at [https://hexdocs.pm/system_engine](https://hexdocs.pm/system_engine).

View File

@@ -19,15 +19,15 @@ import Config
# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason
config :cloudfire,
ecto_repos: [Cloudfire.Repo]
config :cf_phx,
ecto_repos: [CfPhx.Repo]
# Configures the endpoint
config :cloudfire, CloudfireWeb.Endpoint,
config :cf_phx, CfPhxWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "5OVYJ83AcoQcPmdKNksuBhJFBhjHD1uUa9mDOHV/6EIdBQ6pXksIhkVeWIzFk5SD",
render_errors: [view: CloudfireWeb.ErrorView, accepts: ~w(html json)],
pubsub: [name: Cloudfire.PubSub, adapter: Phoenix.PubSub.PG2]
render_errors: [view: CfPhxWeb.ErrorView, accepts: ~w(html json)],
pubsub: [name: CfPhx.PubSub, adapter: Phoenix.PubSub.PG2]
# Configures Elixir's Logger
config :logger, :console,

View File

@@ -1,7 +1,7 @@
import Config
# Configure your database
config :cloudfire, Cloudfire.Repo,
config :cf_phx, CfPhx.Repo,
username: "cloudfire",
password: "postgres",
database: "cloudfire_dev",
@@ -15,7 +15,7 @@ config :cloudfire, Cloudfire.Repo,
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with webpack to recompile .js and .css sources.
config :cloudfire, CloudfireWeb.Endpoint,
config :cf_phx, CfPhxWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
@@ -55,13 +55,13 @@ config :cloudfire, CloudfireWeb.Endpoint,
# different ports.
# Watch static and templates for browser reloading.
config :cloudfire, CloudfireWeb.Endpoint,
config :cf_phx, CfPhxWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/cloudfire_web/(live|views)/.*(ex)$",
~r"lib/cloudfire_web/templates/.*(eex)$"
~r"lib/cf_phx_web/(live|views)/.*(ex)$",
~r"lib/cf_phx_web/templates/.*(eex)$"
]
]

View File

@@ -9,7 +9,7 @@ import Config
# manifest is generated by the `mix phx.digest` task,
# which you should run after static files are built and
# before starting your production server.
config :cloudfire, CloudfireWeb.Endpoint,
config :cf_phx, CfPhxWeb.Endpoint,
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/cache_manifest.json"
@@ -21,7 +21,7 @@ config :logger, level: :info
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
# config :cloudfire, CloudfireWeb.Endpoint,
# config :cf_phx, CfPhxWeb.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [
@@ -45,7 +45,7 @@ config :logger, level: :info
# We also recommend setting `force_ssl` in your endpoint, ensuring
# no data is ever sent via http, always redirecting to https:
#
# config :cloudfire, CloudfireWeb.Endpoint,
# config :cf_phx, CfPhxWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.

View File

@@ -11,7 +11,7 @@ database_url =
For example: ecto://USER:PASS@HOST/DATABASE
"""
config :cloudfire, Cloudfire.Repo,
config :cf_phx, CfPhx.Repo,
# ssl: true,
url: database_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
@@ -23,7 +23,7 @@ secret_key_base =
You can generate one by calling: mix phx.gen.secret
"""
config :cloudfire, CloudfireWeb.Endpoint,
config :cf_phx, CfPhxWeb.Endpoint,
http: [
port: String.to_integer(System.get_env("PORT") || "4000"),
transport_options: [socket_opts: [:inet6]]
@@ -35,7 +35,7 @@ config :cloudfire, CloudfireWeb.Endpoint,
# If you are doing OTP releases, you need to instruct Phoenix
# to start each relevant endpoint:
#
config :cloudfire, CloudfireWeb.Endpoint, server: true
config :cf_phx, CfPhxWeb.Endpoint, server: true
#
# Then you can assemble a release by calling `mix release`.
# See `mix help release` for more information.

View File

@@ -20,11 +20,11 @@ end
# Configure your database
db_url = System.get_env("DATABASE_URL")
config :cloudfire, Cloudfire.Repo, DBConfig.config(db_url)
config :cf_phx, CfPhx.Repo, DBConfig.config(db_url)
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :cloudfire, CloudfireWeb.Endpoint,
config :cf_phx, CfPhxWeb.Endpoint,
http: [port: 4002],
server: false

10
mix.exs
View File

@@ -6,7 +6,15 @@ defmodule CloudfireUmbrella.MixProject do
apps_path: "apps",
version: "0.1.0",
start_permanent: Mix.env() == :prod,
deps: deps()
deps: deps(),
releases: [
bundled: [
applications: [
cf_phx: :permanent,
system_engine: :permanent
]
]
]
]
end