README.md 3.81 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 39
mix run priv/repo/seeds.exs # To initialize a test:test user for testing, inspect file 
                            # for further tweaking (optional)
40
cd assets && npm install    # Install frontend dependencies and tools
Mikko Ahlroth's avatar
Mikko Ahlroth committed
41 42 43 44 45 46
nano config/dev.secret.exs  # Set up dev config with at least the line "use Mix.Config"
                            # at the top
```

### Commands

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

56 57 58 59 60 61 62 63
### Env vars for development

```
RUN_CACHES=true   # If set to any value, will generate user caches even in dev mode, otherwise user
                  # caches will not be generated
MINIFY=true       # If set to true, generated frontend assets will be minified.
```

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
## 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
93

94 95 96 97 98
## Developer/API documentation

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

Mikko Ahlroth's avatar
Mikko Ahlroth committed
99
## Learn more about Phoenix
Mikko Ahlroth's avatar
Mikko Ahlroth committed
100

Mikko Ahlroth's avatar
Mikko Ahlroth committed
101 102 103 104 105
* 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