Skip to content

Commit c56933e

Browse files
committed
init commit
0 parents  commit c56933e

File tree

196 files changed

+24241
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+24241
-0
lines changed

.buildpacks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://github.com/nwittstruck/heroku-buildpack-elixir#scalingo
2+
https://github.com/gigalixir/gigalixir-buildpack-phoenix-static
3+
https://github.com/chrismcg/heroku-buildpack-elixir-mix-release

.devcontainer/devcontainer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
3+
{
4+
"name": "Existing Docker Compose (Extend)",
5+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
6+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
7+
"dockerComposeFile": [
8+
"../docker-compose.yml",
9+
"docker-compose.yml"
10+
],
11+
// The 'service' property is the name of the service for the container that VS Code should
12+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
13+
"service": "wordcharts",
14+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
15+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
16+
"workspaceFolder": "/app/",
17+
"customizations": {
18+
"vscode": {
19+
"extensions": [
20+
"ms-vscode-remote.remote-containers",
21+
"JakeBecker.elixir-ls",
22+
"ms-azuretools.vscode-docker",
23+
"dbaeumer.vscode-eslint"
24+
]
25+
}
26+
},
27+
// Features to add to the dev container. More info: https://containers.dev/features.
28+
// "features": {},
29+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
30+
// "forwardPorts": [],
31+
// Uncomment the next line if you want start specific services in your Docker Compose config.
32+
// "runServices": [],
33+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
34+
"shutdownAction": "none",
35+
// Uncomment the next line to run commands after the container is created.
36+
// "postCreateCommand": "cat /etc/os-release",
37+
// Configure tool-specific properties.
38+
// "customizations": {},
39+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
40+
// "remoteUser": "devcontainer"
41+
}

.devcontainer/docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: '3.8'
2+
services:
3+
# Update this to the name of the service you want to work with in your docker-compose.yml file
4+
wordcharts:
5+
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
6+
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
7+
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
8+
# array). The sample below assumes your primary file is in the root of your project.
9+
#
10+
# build:
11+
# context: .
12+
# dockerfile: .devcontainer/Dockerfile
13+
environment:
14+
SECRET_KEY_BASE: "BeFeHdJtAHmn55ZJCS6bPWbgW2HM1EIljFkk4xTnYwgJlrgkzevyEsLtDUyrxH0d"
15+
16+
volumes:
17+
# Update this to wherever you want VS Code to mount the folder of your project
18+
- ../..:/workspaces:cached
19+
20+
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
21+
# cap_add:
22+
# - SYS_PTRACE
23+
# security_opt:
24+
# - seccomp:unconfined
25+
26+
# Overrides default command so things don't shut down after the process ends.
27+
command: /bin/sh -c "while sleep 1000; do :; done"
28+

.env.default

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Please copy and rename this file.
2+
#
3+
# !Attention!
4+
# Always ensure to load the env variables in every terminal session.
5+
# Otherwise the env variables will not be available
6+
7+
DOCKER_COMPOSE_APP_DATABASE_HOST=postgres
8+
DOCKER_COMPOSE_APP_DATABASE_NAME=wordcharts-dev
9+
DOCKER_COMPOSE_APP_DATABASE_SSL=false
10+
DOCKER_COMPOSE_APP_DATABASE_USER_PASSWORD=wordcharts-user-password
11+
DOCKER_COMPOSE_APP_DATABASE_USER=wordcharts-user
12+
DOCKER_COMPOSE_APP_DEFAULT_LOCALE=en
13+
# This is an example secret key base that can be use in development
14+
# NOTE: There are multiple commands you can use to generate a secret key base. Pick one command you like, e.g. `date +%s | sha256sum | base64 | head -c 64 ; echo`
15+
# !!ATTENTION: DO NOT USE THIS FOR PRODUCTION!!
16+
DOCKER_COMPOSE_APP_SECRET_KEY_BASE=NDliN2UzNjAzMTlmMWIxODZhNzRjMDIzMDY2OTQ5N2Q4NGU3MjUxZjM0YmI0ZGY1
17+
18+
DOCKER_COMPOSE_APP_TEST_DATABASE_HOST=postgres
19+
DOCKER_COMPOSE_APP_TEST_DATABASE_NAME=wordcharts-test
20+
DOCKER_COMPOSE_APP_TEST_DATABASE_USER_PASSWORD=wordcharts-user-password
21+
DOCKER_COMPOSE_APP_TEST_DATABASE_USER=wordcharts-user
22+
23+
DOCKER_COMPOSE_APP_URL_HOST=localhost
24+
DOCKER_COMPOSE_APP_URL_PORT=4000
25+
DOCKER_COMPOSE_APP_URL_SCHEME=http
26+
DOCKER_COMPOSE_APP_PORT_PUBLISHED=4000
27+
DOCKER_COMPOSE_APP_PORT_TARGET=4000
28+
29+
DOCKER_COMPOSE_POSTGRES_DB=wordcharts-dev
30+
DOCKER_COMPOSE_POSTGRES_PASSWORD=wordcharts-user-password
31+
DOCKER_COMPOSE_POSTGRES_PORT=5432
32+
DOCKER_COMPOSE_POSTGRES_PORT_PUBLISHED=5432
33+
DOCKER_COMPOSE_POSTGRES_USER=wordcharts-user
34+
35+
DOCKER_COMPOSE_JS_APP_PORT_PUBLISHED=3000
36+
DOCKER_COMPOSE_JS_APP_PORT_TARGET=3000
37+
38+
DOCKER_COMPOSE_APP_NLP_WORD_TAGGER_BASIC_AUTH_USER_NAME=
39+
DOCKER_COMPOSE_APP_NLP_WORD_TAGGER_BASIC_AUTH_USER_PASSWORD=

.env.prod.default

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Please copy and rename this file.
2+
#
3+
# !Attention!
4+
# Always ensure to load the env variables in every terminal session.
5+
# Otherwise the env variables will not be available
6+
7+
DOCKER_COMPOSE_APP_PROD_DATABASE_NAME=
8+
DOCKER_COMPOSE_APP_PROD_DATABASE_PORT=5432
9+
DOCKER_COMPOSE_APP_PROD_DATABASE_SSL=true
10+
DOCKER_COMPOSE_APP_PROD_DATABASE_HOST=
11+
DOCKER_COMPOSE_APP_PROD_DATABASE_USER=
12+
DOCKER_COMPOSE_APP_PROD_DATABASE_USER_PASSWORD=
13+
DOCKER_COMPOSE_APP_PROD_DEFAULT_LOCALE=en
14+
# Please generate a new secret key base for production
15+
# NOTE: There are multiple commands you can use to generate a secret key base. Pick one command you like, e.g.:
16+
# - `date +%s | sha256sum | base64 | head -c 64 ; echo`
17+
# - `date +%s | shasum -a 256 | base64 | head -c 64 ; echo`
18+
DOCKER_COMPOSE_APP_PROD_SECRET_KEY_BASE=
19+
DOCKER_COMPOSE_APP_PROD_URL_HOST=
20+
DOCKER_COMPOSE_APP_PROD_URL_PORT=443
21+
DOCKER_COMPOSE_APP_URL_SCHEME=https
22+
DOCKER_COMPOSE_APP_PROD_PORT_PUBLISHED=4000
23+
DOCKER_COMPOSE_APP_PROD_PORT_TARGET=4000
24+
25+
DOCKER_COMPOSE_POSTGRES_PROD_DB=
26+
DOCKER_COMPOSE_POSTGRES_PROD_PASSWORD=
27+
DOCKER_COMPOSE_POSTGRES_PROD_PORT=
28+
DOCKER_COMPOSE_POSTGRES_PROD_USER=
29+
30+
DOCKER_COMPOSE_APP_NLP_WORD_TAGGER_BASIC_AUTH_USER_NAME=
31+
DOCKER_COMPOSE_APP_NLP_WORD_TAGGER_BASIC_AUTH_USER_PASSWORD=

.formatter.exs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
import_deps: [:ecto, :phoenix],
3+
inputs: [
4+
"*.{ex,exs}",
5+
"priv/repo/data_migrations/*.{ex,exs}",
6+
"priv/*/seeds.exs",
7+
"{config,lib,test}/**/*.{ex,exs}"
8+
],
9+
subdirectories: ["priv/*/migrations"]
10+
]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'Setup elixir and node'
2+
description: 'Install elixir and node'
3+
inputs:
4+
node-version:
5+
description: 'node version'
6+
required: true
7+
default: '18.12.1'
8+
otp-version:
9+
description: 'otp version'
10+
required: true
11+
default: '26.0.2'
12+
elixir-version:
13+
description: 'elixir version'
14+
required: true
15+
default: '1.15.2'
16+
runs:
17+
using: "composite"
18+
steps:
19+
- uses: erlef/setup-beam@v1
20+
with:
21+
otp-version: ${{inputs.otp-version}}
22+
elixir-version: ${{inputs.elixir-version}}
23+
- run: mix local.hex --force && mix local.rebar --force
24+
shell: bash
25+
- run: mix deps.get
26+
shell: bash
27+
if: steps.cache.outputs.cache-hit != 'true'
28+
29+
- uses: actions/setup-node@v3
30+
with:
31+
node-version: ${{inputs.node-version}}

.github/workflows/ci.yml

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
env:
12+
NODE_VERSION: "18.12.1"
13+
OTP_VERSION: "26.0.2"
14+
ELIXIR_VERSION: "1.15.2"
15+
16+
jobs:
17+
build_deps:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Install node and elixir
23+
uses: ./.github/actions/setup-composite-action
24+
with:
25+
node-version: ${{env.NODE_VERSION}}
26+
otp-version: ${{env.OTP_VERSION}}
27+
elixir-version: ${{env.ELIXIR_VERSION}}
28+
29+
- uses: actions/cache@v3
30+
id: cache-mix
31+
with:
32+
path: deps
33+
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
34+
restore-keys: ${{ runner.os }}-mix-v1
35+
36+
- uses: actions/cache@v3
37+
id: cache-npm
38+
with:
39+
path: frontend/node_modules
40+
key: ${{ runner.os }}-npm-v1-${{ hashFiles('**/frontend/package-lock.json') }}
41+
restore-keys: ${{ runner.os }}-npm-v1
42+
43+
wordcharts-frontend-lint:
44+
runs-on: ubuntu-latest
45+
46+
needs: build_deps
47+
48+
steps:
49+
- uses: actions/checkout@v3
50+
51+
- uses: actions/cache@v3
52+
id: cache-npm
53+
with:
54+
path: deps
55+
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
56+
restore-keys: ${{ runner.os }}-npm-v1
57+
58+
- uses: actions/setup-node@v3
59+
with:
60+
node-version: ${{env.NODE_VERSION}}
61+
62+
- run: npm --prefix frontend ci
63+
64+
- run: npm --prefix frontend run lint
65+
66+
wordcharts-frontend-check-types:
67+
runs-on: ubuntu-latest
68+
69+
needs: build_deps
70+
71+
steps:
72+
- uses: actions/checkout@v3
73+
74+
- uses: actions/cache@v3
75+
id: cache-npm
76+
with:
77+
path: deps
78+
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
79+
restore-keys: ${{ runner.os }}-npm-v1
80+
81+
- uses: actions/setup-node@v3
82+
with:
83+
node-version: ${{env.NODE_VERSION}}
84+
85+
- run: npm --prefix frontend ci
86+
87+
- run: npm --prefix frontend run check-types
88+
89+
wordcharts-frontend-test:
90+
runs-on: ubuntu-latest
91+
92+
needs: build_deps
93+
94+
steps:
95+
- uses: actions/checkout@v3
96+
97+
- uses: actions/cache@v3
98+
id: cache-npm
99+
with:
100+
path: deps
101+
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
102+
restore-keys: ${{ runner.os }}-npm-v1
103+
104+
- uses: actions/setup-node@v3
105+
with:
106+
node-version: ${{env.NODE_VERSION}}
107+
108+
- run: npm --prefix frontend ci
109+
110+
- run: npm --prefix frontend run test
111+
112+
wordcharts-backend-lint:
113+
runs-on: ubuntu-latest
114+
115+
needs: build_deps
116+
117+
steps:
118+
- uses: actions/checkout@v3
119+
120+
- uses: actions/cache@v3
121+
id: cache-mix
122+
with:
123+
path: deps
124+
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
125+
restore-keys: ${{ runner.os }}-mix-v1
126+
127+
- uses: erlef/setup-beam@v1
128+
with:
129+
otp-version: ${{env.OTP_VERSION}}
130+
elixir-version: ${{env.ELIXIR_VERSION}}
131+
132+
- run: mix format
133+
134+
# See https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers
135+
wordcharts-backend-test:
136+
runs-on: ubuntu-latest
137+
needs: build_deps
138+
139+
# Service containers to run with `container-job`
140+
services:
141+
# Label used to access the service container
142+
postgres:
143+
image: postgres:latest
144+
env:
145+
# These env variables are required by the postgres service (see above)
146+
POSTGRES_DB: wordcharts_test
147+
POSTGRES_HOST: postgres
148+
POSTGRES_USER: postgres
149+
POSTGRES_PASSWORD: postgres
150+
ports:
151+
- 5432:5432
152+
153+
# Set health checks to wait until postgres has started
154+
options: >-
155+
--health-cmd pg_isready
156+
--health-interval 10s
157+
--health-timeout 5s
158+
--health-retries 5
159+
env:
160+
# These env vars are required by our application
161+
# Unfortunately, github workflow does not support yaml anchors ;-(
162+
TEST_DATABASE_HOST: localhost
163+
TEST_DATABASE_NAME: wordcharts_test
164+
TEST_DATABASE_USER: postgres
165+
TEST_DATABASE_USER_PASSWORD: postgres
166+
MIX_ENV: "test"
167+
168+
steps:
169+
# Downloads a copy of the code in your repository before running CI tests
170+
- uses: actions/checkout@v3
171+
172+
- name: Install node and elixir
173+
uses: ./.github/actions/setup-composite-action
174+
with:
175+
node-version: ${{env.NODE_VERSION}}
176+
otp-version: ${{env.OTP_VERSION}}
177+
elixir-version: ${{env.ELIXIR_VERSION}}
178+
179+
- uses: actions/cache@v3
180+
id: cache-mix
181+
with:
182+
path: deps
183+
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
184+
restore-keys: ${{ runner.os }}-mix-v1
185+
186+
- uses: actions/cache@v3
187+
id: cache-npm
188+
with:
189+
path: frontend/node_modules
190+
key: ${{ runner.os }}-npm-v1-${{ hashFiles('**/frontend/package-lock.json') }}
191+
restore-keys: ${{ runner.os }}-npm-v1
192+
193+
# install hex:
194+
- run: mix local.hex --force && mix local.rebar --force
195+
- run: mix compile
196+
- run: mix ecto.create
197+
- run: mix ecto.migrate
198+
- run: mix test

0 commit comments

Comments
 (0)