README.md 3.31 KB
Newer Older
Mikko Ahlroth's avatar
Mikko Ahlroth committed
1 2
# Code::Stats

Gitter Badger's avatar
Gitter Badger committed
3 4
[![Join the chat at https://gitter.im/code-stats/Lobby](https://badges.gitter.im/code-stats/Lobby.svg)](https://gitter.im/code-stats/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Mikko Ahlroth's avatar
Mikko Ahlroth committed
5 6 7 8
Code::Stats is a free stats tracking service for programmers: [https://codestats.net/](https://codestats.net/).

This repository contains the Phoenix application that implements the service backend.

9
## Development
Mikko Ahlroth's avatar
Mikko Ahlroth committed
10

Mikko Ahlroth's avatar
Mikko Ahlroth committed
11
### Requirements
Mikko Ahlroth's avatar
Mikko Ahlroth committed
12

13
These are current targets, older versions _might_ work:
Mikko Ahlroth's avatar
Mikko Ahlroth committed
14

Mikko Ahlroth's avatar
Mikko Ahlroth committed
15 16 17 18
* Erlang 21.0+
* Elixir 1.6+
* PostgreSQL 10+
* Node 10+ and NPM
Mikko Ahlroth's avatar
Mikko Ahlroth committed
19 20 21 22

### First time install

```
23 24 25 26
# Database setup for development environment

Set up PostgreSQL matching the settings in `config/dev.exs`.

27
# First create empty versions of required config files for it to compile
28

29 30 31 32
echo use Mix.Config > config/{appsignal,dev.secret}.exs

# Then:

Mikko Ahlroth's avatar
Mikko Ahlroth committed
33 34 35 36 37
mix deps.get                # Get Hex dependencies, answer yes to installing Hex/rebar if
                            # needed
mix compile                 # Compile application
mix ecto.create             # Create database using default credentials
mix ecto.migrate            # Migrate database to latest state
38
cd assets && npm install    # Install frontend dependencies and tools
Mikko Ahlroth's avatar
Mikko Ahlroth committed
39 40 41 42 43 44
nano config/dev.secret.exs  # Set up dev config with at least the line "use Mix.Config"
                            # at the top
```

### Commands

45
* `mix test`: Run all tests suite
46 47
* `mix phx.server`: Run development server on port 5000 (default, you can configure this in
  `dev.secret.exs`)
Mikko Ahlroth's avatar
Mikko Ahlroth committed
48
* `mix frontend.build`: Build the JS/CSS frontend
49
* `mix frontend.watch`: Build the frontend and watch for changes (also run when using `phx.server`)
Mikko Ahlroth's avatar
Mikko Ahlroth committed
50
* `mix frontend.clean`: Clean frontend output and build artifacts
51
* `MINIFY=true mix frontend.build`: Build frontend with minification.
Mikko Ahlroth's avatar
Mikko Ahlroth committed
52

53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
## Production

Generate [Distillery](https://hex.pm/packages/distillery) release:

```
MIX_ENV=prod COOKIE=somesecretcookie mix release --env=prod
```

Note that the release must be generated on the same architecture and OS type as the target system.
So for an amd64 Linux target, use an amd64 Linux build machine. Take note of the cookie you used,
it will be needed to connect to the running instance.

To run release:

```
/path/to/release/code_stats/bin/code_stats migrate    # Migrate database to latest version
/path/to/release/code_stats/bin/code_stats foreground # Run in foreground (current shell)
/path/to/release/code_stats/bin/code_stats start      # Run as daemon
/path/to/release/code_stats/bin/code_stats console    # Run and open console
```

**NOTE:** You will need to set these environment variables when running the release:

```
PORT=1337         # Internal port number that Phoenix will listen on
HOST=some.example # Domain of the website, used for generating links
HOST_PORT=443     # External port of the website, that is used by clients. Can be different to PORT
                  # in case the service is reverse proxied like with Nginx.
```
Mikko Ahlroth's avatar
Mikko Ahlroth committed
82

83 84 85 86 87
## Developer/API documentation

Autogenerated API documentation:
https://code-stats.gitlab.io/code-stats/readme.html

Mikko Ahlroth's avatar
Mikko Ahlroth committed
88
## Learn more about Phoenix
Mikko Ahlroth's avatar
Mikko Ahlroth committed
89

Mikko Ahlroth's avatar
Mikko Ahlroth committed
90 91 92 93 94
* Official website: http://www.phoenixframework.org/
* Guides: http://phoenixframework.org/docs/overview
* Docs: http://hexdocs.pm/phoenix
* Mailing list: http://groups.google.com/group/phoenix-talk
* Source: https://github.com/phoenixframework/phoenix