Skip to content

Commit 5ce1ff1

Browse files
committed
ai clustering working
1 parent befed8e commit 5ce1ff1

78 files changed

Lines changed: 2054 additions & 242 deletions

File tree

Some content is hidden

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

Dockerfile

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-$
2020
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
2121

2222
# This is our base image for development as well as building the production image:
23-
FROM ${BUILDER_IMAGE} as base
23+
FROM ${BUILDER_IMAGE} AS base
2424

2525
# Install node
26-
ENV NODE_MAJOR=18
26+
ENV NODE_MAJOR=22
2727

2828
RUN apt-get -y update
2929

@@ -44,24 +44,27 @@ RUN apt-get update && apt-get install -y nodejs \
4444
apt-get clean && \
4545
rm -f /var/lib/apt/lists/*_*
4646

47-
# prepare build dir
48-
WORKDIR /app
49-
5047
# install hex + rebar
5148
RUN mix local.hex --force && \
5249
mix local.rebar --force
5350

54-
FROM base as development
51+
FROM base AS development
52+
RUN groupadd --gid 1000 elixir \
53+
&& useradd --uid 1000 --gid elixir --shell /bin/bash --create-home elixir
5554

56-
# Install mix dependencies
57-
COPY mix.exs mix.lock ./
58-
RUN mix do deps.get
55+
RUN mkdir -p /usr/local/share/npm-global && \
56+
chown -R elixir:elixir /usr/local/share
5957

60-
# Install npm packages:
61-
COPY assets/package.json assets/package-lock.json ./assets/
62-
RUN npm install --prefix assets
58+
# Install global packages
59+
ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global
60+
ENV PATH=$PATH:/usr/local/share/npm-global/bin
61+
62+
WORKDIR /home/elixir/app
63+
USER elixir
6364

64-
FROM base as production_builder
65+
FROM base AS production_builder
66+
# prepare build dir
67+
WORKDIR /app
6568

6669
# set build ENV
6770
ENV MIX_ENV="prod"
@@ -108,7 +111,7 @@ RUN mix release
108111

109112
# start a new build stage so that the final image will only contain
110113
# the compiled release and other runtime necessities
111-
FROM ${RUNNER_IMAGE} as production
114+
FROM ${RUNNER_IMAGE} AS production
112115

113116
RUN apt-get update -y && apt-get install -y ca-certificates libstdc++6 postgresql-client openssl libncurses5 locales \
114117
&& apt-get clean && rm -f /var/lib/apt/lists/*_*

assets/package-lock.json

Lines changed: 36 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
environment:
88
DATABASE_HOST: ${DOCKER_COMPOSE_APP_DATABASE_HOST:-postgres}
99
DATABASE_NAME: ${DOCKER_COMPOSE_APP_DATABASE_NAME:-mindwendel-dev}
10-
DATABASE_PORT: ${DOCKER_COMPOSE_APP_DATABASE_PORT:-5432}
10+
DATABASE_PORT: ${DOCKER_COMPOSE_POSTGRES_PORT:-5432}
1111
DATABASE_SSL: ${DOCKER_COMPOSE_APP_DATABASE_SSL:-false}
1212
DATABASE_USER_PASSWORD: ${DOCKER_COMPOSE_APP_DATABASE_USER_PASSWORD:-mindwendel-user-password}
1313
DATABASE_USER: ${DOCKER_COMPOSE_APP_DATABASE_USER:-mindwendel-user}
@@ -53,7 +53,7 @@ services:
5353
- postgres
5454
# Mount the lib and test folder to increase development speed (do not use for prod setups!)
5555
volumes:
56-
- ./:/app
56+
- ./:/home/elixir/app
5757
- /app/_build/
5858
- /app/deps/
5959
- /app/assets/node_modules

lib/mindwendel/accounts.ex

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
defmodule Mindwendel.Accounts do
22
import Ecto.Query, warn: false
3-
alias Mindwendel.Repo
3+
alias Mindwendel.Accounts.BrainstormingModeratingUser
44
alias Mindwendel.Accounts.User
55
alias Mindwendel.Brainstormings.Brainstorming
6-
alias Mindwendel.Accounts.BrainstormingModeratingUser
6+
alias Mindwendel.Repo
77

88
require Logger
99

@@ -159,7 +159,9 @@ defmodule Mindwendel.Accounts do
159159

160160
Enum.each(inactive_users, fn inactive_user ->
161161
try do
162-
# first, check if this user is still a moderating user somewhere. in this case, we don't delete the user. we wait until the other brainstorming has been deleted, and delete this user subsequently:
162+
# first, check if this user is still a moderating user somewhere. in this case,
163+
# we don't delete the user. we wait until the other brainstorming has been
164+
# deleted, and delete this user subsequently:
163165
unless user_has_active_brainstormings(inactive_user) do
164166
delete_user(inactive_user)
165167
end
@@ -178,7 +180,8 @@ defmodule Mindwendel.Accounts do
178180
end
179181

180182
def user_has_active_brainstormings(user) do
181-
# check if the user is still listed as creating_user, a moderating user somewhere or if the user is still attached to ideas:
183+
# check if the user is still listed as creating_user, a moderating user somewhere
184+
# or if the user is still attached to ideas:
182185
still_has(user, :created_brainstormings) || still_has(user, :ideas) ||
183186
still_has(user, :moderated_brainstormings)
184187
end

lib/mindwendel/accounts/brainstorming_moderating_user.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
defmodule Mindwendel.Accounts.BrainstormingModeratingUser do
22
# Not using Mindwendel.Schema as the `@derive` in there clashes here
33
use Ecto.Schema
4-
alias Mindwendel.Brainstormings.Brainstorming
54
alias Mindwendel.Accounts.User
5+
alias Mindwendel.Brainstormings.Brainstorming
66

77
@primary_key false
88
schema "brainstorming_moderating_users" do

lib/mindwendel/accounts/brainstorming_user.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Mindwendel.Accounts.BrainstormingUser do
22
use Mindwendel.Schema
3-
alias Mindwendel.Brainstormings.Brainstorming
43
alias Mindwendel.Accounts.User
4+
alias Mindwendel.Brainstormings.Brainstorming
55

66
schema "brainstorming_users" do
77
belongs_to :brainstorming, Brainstorming

lib/mindwendel/accounts/user.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ defmodule Mindwendel.Accounts.User do
33

44
import Ecto.Changeset
55

6-
alias Mindwendel.Brainstormings.Brainstorming
7-
alias Mindwendel.Brainstormings.Idea
86
alias Mindwendel.Accounts.BrainstormingModeratingUser
97
alias Mindwendel.Accounts.BrainstormingUser
8+
alias Mindwendel.Brainstormings.Brainstorming
9+
alias Mindwendel.Brainstormings.Idea
1010

1111
schema "users" do
1212
field :username, :string, default: "Anonymous"

0 commit comments

Comments
 (0)