Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek committed Dec 22, 2023
0 parents commit c56933e
Show file tree
Hide file tree
Showing 196 changed files with 24,241 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .buildpacks
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/nwittstruck/heroku-buildpack-elixir#scalingo
https://github.com/gigalixir/gigalixir-buildpack-phoenix-static
https://github.com/chrismcg/heroku-buildpack-elixir-mix-release
41 changes: 41 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "Existing Docker Compose (Extend)",
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.yml"
],
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "wordcharts",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/app/",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode-remote.remote-containers",
"JakeBecker.elixir-ls",
"ms-azuretools.vscode-docker",
"dbaeumer.vscode-eslint"
]
}
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
"shutdownAction": "none",
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
28 changes: 28 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '3.8'
services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
wordcharts:
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
# array). The sample below assumes your primary file is in the root of your project.
#
# build:
# context: .
# dockerfile: .devcontainer/Dockerfile
environment:
SECRET_KEY_BASE: "BeFeHdJtAHmn55ZJCS6bPWbgW2HM1EIljFkk4xTnYwgJlrgkzevyEsLtDUyrxH0d"

volumes:
# Update this to wherever you want VS Code to mount the folder of your project
- ../..:/workspaces:cached

# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
# cap_add:
# - SYS_PTRACE
# security_opt:
# - seccomp:unconfined

# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"

39 changes: 39 additions & 0 deletions .env.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Please copy and rename this file.
#
# !Attention!
# Always ensure to load the env variables in every terminal session.
# Otherwise the env variables will not be available

DOCKER_COMPOSE_APP_DATABASE_HOST=postgres
DOCKER_COMPOSE_APP_DATABASE_NAME=wordcharts-dev
DOCKER_COMPOSE_APP_DATABASE_SSL=false
DOCKER_COMPOSE_APP_DATABASE_USER_PASSWORD=wordcharts-user-password
DOCKER_COMPOSE_APP_DATABASE_USER=wordcharts-user
DOCKER_COMPOSE_APP_DEFAULT_LOCALE=en
# This is an example secret key base that can be use in development
# 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`
# !!ATTENTION: DO NOT USE THIS FOR PRODUCTION!!
DOCKER_COMPOSE_APP_SECRET_KEY_BASE=NDliN2UzNjAzMTlmMWIxODZhNzRjMDIzMDY2OTQ5N2Q4NGU3MjUxZjM0YmI0ZGY1

DOCKER_COMPOSE_APP_TEST_DATABASE_HOST=postgres
DOCKER_COMPOSE_APP_TEST_DATABASE_NAME=wordcharts-test
DOCKER_COMPOSE_APP_TEST_DATABASE_USER_PASSWORD=wordcharts-user-password
DOCKER_COMPOSE_APP_TEST_DATABASE_USER=wordcharts-user

DOCKER_COMPOSE_APP_URL_HOST=localhost
DOCKER_COMPOSE_APP_URL_PORT=4000
DOCKER_COMPOSE_APP_URL_SCHEME=http
DOCKER_COMPOSE_APP_PORT_PUBLISHED=4000
DOCKER_COMPOSE_APP_PORT_TARGET=4000

DOCKER_COMPOSE_POSTGRES_DB=wordcharts-dev
DOCKER_COMPOSE_POSTGRES_PASSWORD=wordcharts-user-password
DOCKER_COMPOSE_POSTGRES_PORT=5432
DOCKER_COMPOSE_POSTGRES_PORT_PUBLISHED=5432
DOCKER_COMPOSE_POSTGRES_USER=wordcharts-user

DOCKER_COMPOSE_JS_APP_PORT_PUBLISHED=3000
DOCKER_COMPOSE_JS_APP_PORT_TARGET=3000

DOCKER_COMPOSE_APP_NLP_WORD_TAGGER_BASIC_AUTH_USER_NAME=
DOCKER_COMPOSE_APP_NLP_WORD_TAGGER_BASIC_AUTH_USER_PASSWORD=
31 changes: 31 additions & 0 deletions .env.prod.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Please copy and rename this file.
#
# !Attention!
# Always ensure to load the env variables in every terminal session.
# Otherwise the env variables will not be available

DOCKER_COMPOSE_APP_PROD_DATABASE_NAME=
DOCKER_COMPOSE_APP_PROD_DATABASE_PORT=5432
DOCKER_COMPOSE_APP_PROD_DATABASE_SSL=true
DOCKER_COMPOSE_APP_PROD_DATABASE_HOST=
DOCKER_COMPOSE_APP_PROD_DATABASE_USER=
DOCKER_COMPOSE_APP_PROD_DATABASE_USER_PASSWORD=
DOCKER_COMPOSE_APP_PROD_DEFAULT_LOCALE=en
# Please generate a new secret key base for production
# 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`
# - `date +%s | shasum -a 256 | base64 | head -c 64 ; echo`
DOCKER_COMPOSE_APP_PROD_SECRET_KEY_BASE=
DOCKER_COMPOSE_APP_PROD_URL_HOST=
DOCKER_COMPOSE_APP_PROD_URL_PORT=443
DOCKER_COMPOSE_APP_URL_SCHEME=https
DOCKER_COMPOSE_APP_PROD_PORT_PUBLISHED=4000
DOCKER_COMPOSE_APP_PROD_PORT_TARGET=4000

DOCKER_COMPOSE_POSTGRES_PROD_DB=
DOCKER_COMPOSE_POSTGRES_PROD_PASSWORD=
DOCKER_COMPOSE_POSTGRES_PROD_PORT=
DOCKER_COMPOSE_POSTGRES_PROD_USER=

DOCKER_COMPOSE_APP_NLP_WORD_TAGGER_BASIC_AUTH_USER_NAME=
DOCKER_COMPOSE_APP_NLP_WORD_TAGGER_BASIC_AUTH_USER_PASSWORD=
10 changes: 10 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
import_deps: [:ecto, :phoenix],
inputs: [
"*.{ex,exs}",
"priv/repo/data_migrations/*.{ex,exs}",
"priv/*/seeds.exs",
"{config,lib,test}/**/*.{ex,exs}"
],
subdirectories: ["priv/*/migrations"]
]
31 changes: 31 additions & 0 deletions .github/actions/setup-composite-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Setup elixir and node'
description: 'Install elixir and node'
inputs:
node-version:
description: 'node version'
required: true
default: '18.12.1'
otp-version:
description: 'otp version'
required: true
default: '26.0.2'
elixir-version:
description: 'elixir version'
required: true
default: '1.15.2'
runs:
using: "composite"
steps:
- uses: erlef/setup-beam@v1
with:
otp-version: ${{inputs.otp-version}}
elixir-version: ${{inputs.elixir-version}}
- run: mix local.hex --force && mix local.rebar --force
shell: bash
- run: mix deps.get
shell: bash
if: steps.cache.outputs.cache-hit != 'true'

- uses: actions/setup-node@v3
with:
node-version: ${{inputs.node-version}}
198 changes: 198 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
name: Docker Image CI

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
NODE_VERSION: "18.12.1"
OTP_VERSION: "26.0.2"
ELIXIR_VERSION: "1.15.2"

jobs:
build_deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install node and elixir
uses: ./.github/actions/setup-composite-action
with:
node-version: ${{env.NODE_VERSION}}
otp-version: ${{env.OTP_VERSION}}
elixir-version: ${{env.ELIXIR_VERSION}}

- uses: actions/cache@v3
id: cache-mix
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-v1

- uses: actions/cache@v3
id: cache-npm
with:
path: frontend/node_modules
key: ${{ runner.os }}-npm-v1-${{ hashFiles('**/frontend/package-lock.json') }}
restore-keys: ${{ runner.os }}-npm-v1

wordcharts-frontend-lint:
runs-on: ubuntu-latest

needs: build_deps

steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
id: cache-npm
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-npm-v1

- uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}

- run: npm --prefix frontend ci

- run: npm --prefix frontend run lint

wordcharts-frontend-check-types:
runs-on: ubuntu-latest

needs: build_deps

steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
id: cache-npm
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-npm-v1

- uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}

- run: npm --prefix frontend ci

- run: npm --prefix frontend run check-types

wordcharts-frontend-test:
runs-on: ubuntu-latest

needs: build_deps

steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
id: cache-npm
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-npm-v1

- uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}

- run: npm --prefix frontend ci

- run: npm --prefix frontend run test

wordcharts-backend-lint:
runs-on: ubuntu-latest

needs: build_deps

steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
id: cache-mix
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-v1

- uses: erlef/setup-beam@v1
with:
otp-version: ${{env.OTP_VERSION}}
elixir-version: ${{env.ELIXIR_VERSION}}

- run: mix format

# See https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers
wordcharts-backend-test:
runs-on: ubuntu-latest
needs: build_deps

# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
image: postgres:latest
env:
# These env variables are required by the postgres service (see above)
POSTGRES_DB: wordcharts_test
POSTGRES_HOST: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432

# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
# These env vars are required by our application
# Unfortunately, github workflow does not support yaml anchors ;-(
TEST_DATABASE_HOST: localhost
TEST_DATABASE_NAME: wordcharts_test
TEST_DATABASE_USER: postgres
TEST_DATABASE_USER_PASSWORD: postgres
MIX_ENV: "test"

steps:
# Downloads a copy of the code in your repository before running CI tests
- uses: actions/checkout@v3

- name: Install node and elixir
uses: ./.github/actions/setup-composite-action
with:
node-version: ${{env.NODE_VERSION}}
otp-version: ${{env.OTP_VERSION}}
elixir-version: ${{env.ELIXIR_VERSION}}

- uses: actions/cache@v3
id: cache-mix
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-v1

- uses: actions/cache@v3
id: cache-npm
with:
path: frontend/node_modules
key: ${{ runner.os }}-npm-v1-${{ hashFiles('**/frontend/package-lock.json') }}
restore-keys: ${{ runner.os }}-npm-v1

# install hex:
- run: mix local.hex --force && mix local.rebar --force
- run: mix compile
- run: mix ecto.create
- run: mix ecto.migrate
- run: mix test
Loading

0 comments on commit c56933e

Please sign in to comment.