Skip to content

Commit

Permalink
Fix poxa.conf and schema
Browse files Browse the repository at this point in the history
  • Loading branch information
edgurgel committed Oct 10, 2017
1 parent b1adfbf commit 4cdf8b2
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 59 deletions.
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM msaraiva/elixir-dev:1.2.4
FROM elixir:1.5.2-alpine

ENV APP_NAME poxa
ENV MIX_ENV prod

RUN apk --update add erlang-xmerl erlang-crypto erlang-sasl && rm -rf /var/cache/apk/*
RUN apk --update add bash git erlang-xmerl erlang-crypto erlang-sasl && rm -rf /var/cache/apk/*

COPY . /source
WORKDIR /source

RUN mix local.hex --force && mix local.rebar --force
RUN MIX_ENV=prod mix deps.get
RUN MIX_ENV=prod mix compile
RUN MIX_ENV=prod mix release --verbosity=verbose --no-confirm-missing
RUN mkdir /app && cp -r rel/$APP_NAME /app && rm -rf /source
RUN mix deps.get
RUN mix compile
RUN mix release

CMD trap exit TERM; /app/$APP_NAME/bin/$APP_NAME foreground & wait
RUN mkdir /app && cp -r _build/prod/rel/$APP_NAME /app && rm -rf /source

CMD /app/$APP_NAME/bin/$APP_NAME foreground
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ MIX_ENV=prod mix do deps.get, compile, release
Then you can run it using:

```console
$ ./rel/poxa/bin/poxa
$ _build/prod/rel/poxa/bin/poxa
Usage: poxa {start|start_boot <file>|foreground|stop|restart|reboot|ping|rpc <m> <f> [<a>]|console|console_clean|console_boot <file>|attach|remote_console|upgrade}
```

To start as daemon you just need to:

```console
./rel/poxa/bin/poxa start
$ _build/prod/rel/poxa/bin/poxa start
```

### Release configuration
Expand All @@ -169,6 +169,30 @@ poxa.app_id = "app_id"

You can change anything on this file and just start the release and this configuration will be used.

#### Environment variables

The .conf file is not the only way to configure a release. The following environment variables are supported:

* `PORT`
* `POXA_APP_KEY`
* `POXA_SECRET`
* `POXA_APP_ID`
* `POXA_REGISTRY_ADAPTER`
* `WEB_HOOK`
* `POXA_SSL`
* `SSL_PORT`
* `SSL_CACERTFILE`
* `SSL_CERTFILE`
* `SSL_KEYFILE`

Even if the file is not used at all, an empty file must exist or you will get this error:

```
missing .conf, expected it at /Users/eduardo/workspace/poxa/_build/dev/rel/poxa/releases/0.7.0/poxa.conf
```

It is very important that the .conf file does not have the same configuration. For example if both `PORT` and `poxa.port` (inside the .conf file) are defined, then the file will have precedence.

## Using Docker

Docker images are automatically built by [Docker Hub](https://hub.docker.com/r/edgurgel/poxa-automated/builds/). They are available at Docker Hub: https://hub.docker.com/r/edgurgel/poxa-automated/tags/
Expand Down
32 changes: 0 additions & 32 deletions config/poxa.conf

This file was deleted.

44 changes: 44 additions & 0 deletions config/poxa.dev.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# HTTP Port
# If not set, will use value of PORT environment variable
poxa.port = 8080

# Pusher app key
# If not set, will use value of POXA_APP_KEY environment variable
poxa.app_key = "app_key"

# Pusher secret
# If not set, will use value of POXA_SECRET environment variable
poxa.app_secret = "secret"

# Pusher app id
# If not set, will use value of POXA_APP_ID environment variable
poxa.app_id = "app_id"

# Registry adapter
# If not set, will use value of POXA_REGISTRY_ADAPTER environment variable
poxa.registry_adapter = "gproc"

# Web hook endpoint
# If not set, will use value of WEB_HOOK environment variable
# poxa.web_hook =

# HTTPS switch
# If not set, will use value of POXA_SSL environment variable
poxa.ssl.enabled = false

# HTTPS port
# If not set, will use value of SSL_PORT environment variable
# poxa.ssl.port =

# PEM-encoded CA certificate path
# If not set, will use value of SSL_CACERTFILE environment variable
# poxa.ssl.cacertfile =

# Path to user certificate
# If not set, will use value of SSL_CERTFILE environment variable
# poxa.ssl.certfile =

# Path to the file containing the user's private PEM-encoded key
# If not set, will use value of SSL_KEYFILE environment variable
# poxa.ssl.keyfile =

56 changes: 39 additions & 17 deletions config/poxa.schema.exs
Original file line number Diff line number Diff line change
@@ -1,75 +1,97 @@
[
extends: [],
import: [],
mappings: [
"poxa.port": [
doc: "HTTP port",
to: "poxa.port",
commented: false,
datatype: :integer,
default: 8080
default: 8080,
doc: "HTTP Port",
hidden: false,
env_var: "PORT",
to: "poxa.port"
],
"poxa.app_key": [
doc: "Pusher app key",
to: "poxa.app_key",
commented: false,
datatype: :binary,
default: "app_key"
default: "app_key",
doc: "Pusher app key",
hidden: false,
env_var: "POXA_APP_KEY",
to: "poxa.app_key"
],
"poxa.app_secret": [
doc: "Pusher secret",
to: "poxa.app_secret",
commented: false,
datatype: :binary,
default: "secret"
default: "secret",
doc: "Pusher secret",
hidden: false,
env_var: "POXA_SECRET",
to: "poxa.app_secret"
],
"poxa.app_id": [
doc: "Pusher app id",
to: "poxa.app_id",
commented: false,
datatype: :binary,
default: "app_id"
default: "app_id",
doc: "Pusher app id",
hidden: false,
env_var: "POXA_APP_ID",
to: "poxa.app_id"
],
"poxa.registry_adapter": [
commented: false,
datatype: :binary,
default: "gproc",
doc: "Registry adapter",
hidden: false,
env_var: "POXA_REGISTRY_ADAPTER",
to: "poxa.registry_adapter"
],
"poxa.web_hook": [
commented: true,
datatype: :atom,
commented: false,
datatype: :binary,
doc: "Web hook endpoint",
hidden: false,
default: "",
env_var: "WEB_HOOK",
to: "poxa.web_hook"
],
],
"poxa.ssl.enabled": [
doc: "HTTPS switch",
to: "poxa.ssl.enabled",
datatype: :boolean,
env_var: "POXA_SSL",
default: false,
],
"poxa.ssl.port": [
doc: "HTTPS port",
to: "poxa.ssl.port",
env_var: "SSL_PORT",
default: 8443,
datatype: :integer,
],
"poxa.ssl.cacertfile": [
doc: "PEM-encoded CA certificate path",
to: "poxa.ssl.cacertfile",
env_var: "SSL_CACERTFILE",
default: "",
datatype: :binary,
],
"poxa.ssl.certfile": [
doc: "Path to user certificate",
to: "poxa.ssl.certfile",
env_var: "SSL_CERTFILE",
default: "",
datatype: :binary,
],
"poxa.ssl.keyfile": [
doc: "Path to the file containing the user's private PEM-encoded key",
to: "poxa.ssl.keyfile",
env_var: "SSL_KEYFILE",
default: "",
datatype: :binary,
]
],
translations: [
]
transforms: [],
validators: []
]
1 change: 0 additions & 1 deletion rel/relx.config

This file was deleted.

0 comments on commit 4cdf8b2

Please sign in to comment.