Skip to content

Commit

Permalink
Claper v2 (#88)
Browse files Browse the repository at this point in the history
Check the changelog
  • Loading branch information
alxlion committed Apr 26, 2024
1 parent 2cdf3f4 commit 6d26c0e
Show file tree
Hide file tree
Showing 123 changed files with 8,943 additions and 4,283 deletions.
44 changes: 29 additions & 15 deletions .env.sample
@@ -1,25 +1,39 @@
BASE_URL=http://localhost:4000
# SAME_SITE_COOKIE=Lax
# SECURE_COOKIE=false

DATABASE_URL=postgres://claper:claper@db:5432/claper
SECRET_KEY_BASE=0LZiQBLw4WvqPlz4cz8RsHJlxNiSqM9B48y4ChyJ5v1oA0L/TPIqRjQNdPZN3iEG # Generate with `mix phx.gen.secret`
# ⚠️ Don't use this exact value for SECRET_KEY_BASE or someone would be able to sign a cookie with user_id=1 and log in as the admin!

# Storage configuration

PRESENTATION_STORAGE=local
PRESENTATION_STORAGE_DIR=/app/uploads
MAX_FILE_SIZE_MB=15
#MAX_FILE_SIZE_MB=15

AWS_ACCESS_KEY_ID=xxx
AWS_SECRET_ACCESS_KEY=xxx
AWS_REGION=eu-west-3
AWS_PRES_BUCKET=xxx
#AWS_ACCESS_KEY_ID=xxx
#AWS_SECRET_ACCESS_KEY=xxx
#AWS_REGION=eu-west-3
#AWS_PRES_BUCKET=xxx

SMTP_RELAY=xx.example.com
SMTP_USERNAME=johndoe@example.com
SMTP_PASSWORD=xxx
SMTP_PORT=465
SMTP_TLS=if_available
# Mail configuration

MAIL_TRANSPORT=local
MAIL_FROM=noreply@claper.co
MAIL_FROM_NAME=Claper

ENABLE_ACCOUNT_CREATION=true
ENABLE_MAILBOX_ROUTE=false
MAILBOX_USER=admin
MAILBOX_PASSWORD=admin
#SMTP_RELAY=xx.example.com
#SMTP_USERNAME=johndoe@example.com
#SMTP_PASSWORD=xxx
#SMTP_PORT=465
#SMTP_TLS=if_available

#ENABLE_MAILBOX_ROUTE=false
#MAILBOX_USER=admin
#MAILBOX_PASSWORD=admin

# Claper configuration

GS_JPG_RESOLUTION=300x300
#ENABLE_ACCOUNT_CREATION=true
#GS_JPG_RESOLUTION=300x300
6 changes: 3 additions & 3 deletions .formatter.exs
@@ -1,6 +1,6 @@
[
import_deps: [:ecto, :phoenix],
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"],
import_deps: [:ecto, :ecto_sql, :phoenix],
subdirectories: ["priv/*/migrations"],
plugins: [Phoenix.LiveView.HTMLFormatter]
plugins: [Phoenix.LiveView.HTMLFormatter],
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"]
]
36 changes: 0 additions & 36 deletions .github/workflows/doc.yml

This file was deleted.

19 changes: 4 additions & 15 deletions .github/workflows/docker-image.yml
Expand Up @@ -48,23 +48,12 @@ jobs:
uses: docker/build-push-action@v2.10.0
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push ARM Docker image
# You may pin to the exact commit or the version.
# uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
uses: docker/build-push-action@v2.10.0
with:
context: .
file: ./Dockerfile-arm
push: true
platforms: linux/arm64
tags: ${{ steps.meta.outputs.tags }}-arm
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max


build-args: |
BUILD_METADATA=${{ steps.meta.outputs.json }}
ERL_FLAGS=+JPperf true
7 changes: 4 additions & 3 deletions .github/workflows/elixir.yml
Expand Up @@ -18,7 +18,7 @@ jobs:

services:
db:
image: postgres:9
image: postgres:15
ports: ['5432:5432']
env:
POSTGRES_PASSWORD: claper
Expand All @@ -34,6 +34,7 @@ jobs:
MIX_ENV: test
DATABASE_URL: postgresql://claper:claper@localhost:5432/claper
SECRET_KEY_BASE: QMQE4ypfy0IC1LZI/fygZNvXHPjLslnr49EE7ftcL1wgAC0MwMLdKCVJyrvXPu8z
BASE_URL: http://localhost:4000

steps:
- uses: actions/checkout@v3
Expand All @@ -42,8 +43,8 @@ jobs:
- name: Set up Elixir
uses: erlef/setup-beam@988e02bfe678367a02564f65ca2e37726dc0268f
with:
elixir-version: '1.13.2'
otp-version: '24.1'
elixir-version: '1.15.4'
otp-version: '26'
- name: Restore dependencies cache
uses: actions/cache@v3
with:
Expand Down
34 changes: 28 additions & 6 deletions CHANGELOG.md
@@ -1,3 +1,30 @@
## v2.0.0

### Features

- Add dynamic layout in the manager view
- Add quick event feature
- Add question feature
- Add toggle for message reactions in attendees room
- Add toggle for polls results in attendees room
- Add delete account button in user settings
- Add language switcher in user settings
- Add tour guide for new users
- Add headers to exported CSV in reports
- Add spanish locale (#84) (@eduproinf)

### Fixes and improvements

- Improve Docker image to support both ARM and AMD64 architecture
- Change date picker for a more user-friendly one
- Upgrade Ecto, Phoenix and LiveView
- Fix user avatars in reports
- Fix average voters stats
- Fix some UI/UX issues
- Remove end date for events
- Replace `ENDPOINT_PORT` and `ENDPOINT_HOST` with `BASE_URL` environment variable
- Add `SAME_SITE_COOKIE` and `SECURE_COOKIE` environment variables

## v1.7.0

- Add keyboard shortcuts to control settings (#64) (@Dhanus3133)
Expand All @@ -12,6 +39,7 @@
- Security updates

## v1.6.0

- Improve QR code readability
- Add ARM Docker image
- Refactor all runtime configuration
Expand Down Expand Up @@ -46,33 +74,28 @@
- Add MAX_FILE_SIZE_MB environment variable to limit file upload size
- Add feature to deactivate messages during a presentation


## v1.3.0

- Add Form feature to collect data from your public
- Improve docs for Docker Compose
- Improve Docker Compose file reference


## v1.2.1

- Fix presenter url (400 error in production)


## v1.2.0

- Added password change form in settings
- Added more documentation on deployment in production


## v1.1.1

_Security updates_

- Added `ENABLE_MAILBOX_ROUTE`, `MAILBOX_USER` and `MAILBOX_PASSWORD` environment variables to enable/disable route to local mailbox (`/dev/mailbox`) and basic auth (optional)
- Restricted `/users/register` route if `ENABLE_ACCOUNT_CREATION` is false


## v1.1.0

- Added password authentication
Expand All @@ -81,7 +104,6 @@ _Security updates_
- Added new `ENABLE_ACCOUNT_CREATION` environment variable to enable or disable user registration
- Improved french localization


## v1.0.0

This is the first version of the open-source project. Feel free to contribute!
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -11,4 +11,9 @@ Don't forget to give the project a star! Thanks again!

## Translations

You can contribute to the translations by editing or addind PO files in `/priv/gettext/`
You can contribute to the translations by editing the files in `/priv/gettext/`
Each language has its own directory with the `.po` files. The country code is used as the directory name and following the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) nomenclature, for example, `en` for English, `fr` for French, `de` for German. You can find the list of country codes [here](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes).

### Add new language

To add a new language, you can copy the `en` directory and rename it with the country code of the new language. Then you can edit the `.po` files with the translations.
76 changes: 42 additions & 34 deletions Dockerfile
Expand Up @@ -12,30 +12,36 @@
# - https://pkgs.org/ - resource for finding needed packages
# - Ex: hexpm/elixir:1.13.2-erlang-24.2.1-debian-bullseye-20210902-slim
#
ARG BUILDER_IMAGE="hexpm/elixir:1.13.2-erlang-24.2.1-debian-bullseye-20210902-slim"
ARG RUNNER_IMAGE="debian:bullseye-20210902-slim"
ARG BUILDER_IMAGE="hexpm/elixir:1.16.0-erlang-26.2.1-alpine-3.18.4"
ARG RUNNER_IMAGE="alpine:3.18.4"

FROM ${BUILDER_IMAGE} as builder

# install build dependencies
RUN apt-get update -y && apt-get install -y curl build-essential git \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
# RUN apt-get update -y && apt-get install -y curl build-essential git \
# && apt-get clean && rm -f /var/lib/apt/lists/*_*
RUN apk add --no-cache -U build-base git curl bash ca-certificates nodejs npm openssl ncurses

ENV NODE_VERSION 16.20.0
ENV PRESENTATION_STORAGE_DIR /app/uploads

# custom ERL_FLAGS are passed for (public) multi-platform builds
# to fix qemu segfault, more info: https://github.com/erlang/otp/pull/6340
ARG ERL_FLAGS
ENV ERL_FLAGS=$ERL_FLAGS

# Install nvm with node and npm
RUN curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash \
&& . $HOME/.nvm/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
# RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \
# && . $HOME/.nvm/nvm.sh \
# && nvm install $NODE_VERSION \
# && nvm alias default $NODE_VERSION \
# && nvm use default

ENV NODE_PATH $HOME/.nvm/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH $HOME/.nvm/versions/node/v$NODE_VERSION/bin:$PATH
# ENV NODE_PATH $HOME/.nvm/versions/node/v$NODE_VERSION/lib/node_modules
# ENV PATH $HOME/.nvm/versions/node/v$NODE_VERSION/bin:$PATH

RUN ln -sf $HOME/.nvm/versions/node/v$NODE_VERSION/bin/npm /usr/bin/npm
RUN ln -sf $HOME/.nvm/versions/node/v$NODE_VERSION/bin/node /usr/bin/node
# RUN ln -sf $HOME/.nvm/versions/node/v$NODE_VERSION/bin/npm /usr/bin/npm
# RUN ln -sf $HOME/.nvm/versions/node/v$NODE_VERSION/bin/node /usr/bin/node

# prepare build dir
WORKDIR /app
Expand Down Expand Up @@ -71,8 +77,12 @@ COPY lib lib

RUN mix compile

RUN npm install -g sass
RUN cd assets && npm i && \
sass --no-source-map --style=compressed css/custom.scss ../priv/static/assets/custom.css

# compile assets
RUN mix assets.deploy
RUN mix assets.deploy.nosass

# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/
Expand All @@ -84,34 +94,32 @@ RUN mix release
# the compiled release and other runtime necessities
FROM ${RUNNER_IMAGE}

RUN apt-get update -y && apt-get install -y libstdc++6 openssl libncurses5 locales ghostscript \
&& apt-get install -y libreoffice --no-install-recommends && apt-get clean && rm -f /var/lib/apt/lists/*_*
# RUN apt-get update -y && apt-get install -y curl libstdc++6 openssl libncurses5 locales ghostscript default-jre libreoffice-java-common \
# && apt-get install -y libreoffice --no-install-recommends && apt-get clean && rm -f /var/lib/apt/lists/*_*
RUN apk add --no-cache curl libstdc++6 openssl ncurses ghostscript openjdk11-jre

# Install LibreOffice & Common Fonts
RUN apk --no-cache add bash libreoffice util-linux libreoffice-common \
font-droid-nonlatin font-droid ttf-dejavu ttf-freefont ttf-liberation && \
rm -rf /var/cache/apk/*

# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
# Install Microsoft Core Fonts
RUN apk --no-cache add msttcorefonts-installer fontconfig && \
update-ms-fonts && \
fc-cache -f && \
rm -rf /var/cache/apk/*

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV HOME "/home/nobody"

RUN mkdir /home/nobody && chown nobody /home/nobody
ENV MIX_ENV="prod"

WORKDIR "/app"
RUN mkdir /app/uploads
RUN chown -R nobody /app

# Only copy the final release from the build stage
COPY --from=builder --chown=nobody:root /app/_build/prod/rel/claper ./

RUN chmod +x /app/bin/*

USER nobody
COPY --from=builder --chmod=a+rX /app/_build/prod/rel/claper /app
RUN mkdir /app/uploads && chmod -R 777 /app/uploads

EXPOSE 4000

WORKDIR "/app"
USER root
CMD ["sh", "-c", "/app/bin/claper eval Claper.Release.migrate && /app/bin/claper start"]

# Appended by flyctl
#ENV ECTO_IPV6 true
#ENV ERL_AFLAGS "-proto_dist inet6_tcp"

0 comments on commit 6d26c0e

Please sign in to comment.