diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ca4a89d..c723f87 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -45,15 +45,13 @@ jobs: - name: Build and push 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 + uses: docker/build-push-action@v6 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 build-args: | BUILD_METADATA=${{ steps.meta.outputs.json }} ERL_FLAGS=+JPperf true \ No newline at end of file diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index 98200a7..0000000 --- a/.tool-versions +++ /dev/null @@ -1,2 +0,0 @@ -erlang 26.2.5.6 -elixir 1.18.0-otp-26 diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..d502072 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,92 @@ +FROM ubuntu:22.04 + +# Set bash as the default shell +SHELL ["/bin/bash", "-c"] + +# Avoid prompts during package installation +ENV DEBIAN_FRONTEND=noninteractive + +# Set up timezone +RUN apt-get update && apt-get install -y tzdata \ + && ln -fs /usr/share/zoneinfo/UTC /etc/localtime \ + && dpkg-reconfigure -f noninteractive tzdata + +# Install dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + git \ + curl \ + wget \ + gnupg \ + ca-certificates \ + apt-transport-https \ + lsb-release \ + python3 \ + openssl \ + libncurses5-dev \ + locales \ + inotify-tools \ + unzip \ + automake \ + autoconf \ + libreadline-dev \ + libssl-dev \ + libyaml-dev \ + libxslt-dev \ + libffi-dev \ + libtool \ + openjdk-11-jdk \ + ghostscript \ + libreoffice \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Set locale +RUN locale-gen en_US.UTF-8 +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + +# Install asdf +ENV ASDF_VERSION=0.18.0 + +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then \ + ASDF_ARCH="arm64"; \ + else \ + ASDF_ARCH="amd64"; \ + fi && \ + wget https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-${ASDF_ARCH}.tar.gz \ + && tar -xzf asdf-v${ASDF_VERSION}-linux-${ASDF_ARCH}.tar.gz \ + && rm asdf-v${ASDF_VERSION}-linux-${ASDF_ARCH}.tar.gz \ + && mv asdf /usr/bin/ + + +# Install Erlang and Elixir using asdf +RUN asdf plugin add erlang \ + && asdf plugin add elixir \ + && asdf install erlang 26.2.1 \ + && asdf install elixir 1.16.0 \ + && asdf set -u erlang 26.2.1 \ + && asdf set -u elixir 1.16.0 + +# Install Node.js using asdf +RUN asdf plugin add nodejs \ + && asdf install nodejs 22.1.0 \ + && asdf set -u nodejs 22.1.0 + +ENV PATH="/root/.asdf/shims:$PATH" + +# Install Hex and Phoenix +RUN mix local.hex --force \ + && mix local.rebar --force \ + && mix archive.install hex phx_new --force + +# custom ERL_FLAGS are passed for (public) multi-platform builds +ARG ERL_FLAGS +ENV ERL_FLAGS=$ERL_FLAGS + +EXPOSE 4000 +USER root +WORKDIR /app +ENTRYPOINT ["bash", "-c", "mix deps.get && mix ecto.migrate && cd assets && npm i && cd .. && mix phx.server"] diff --git a/README.md b/README.md index 47b1ee9..e56581b 100644 --- a/README.md +++ b/README.md @@ -45,58 +45,11 @@ Claper is proudly powered by Phoenix and Elixir. ### Our partners and sponsors LMDDC -Pixilearn -UCCS ## Documentation You can find all the instructions and configuration in [the documentation](https://docs.claper.co/). -## Development environment - -### Prerequisites - -To run Claper on your local environment you need to have: - -- Postgres >= 15 -- Elixir >= 1.16 -- Erlang >= 26 -- NPM >= 10 -- NodeJS >= 20 -- Ghostscript >= 9 (for PDF support) -- Libreoffice >= 24 (for PPT/PPTX support) - -### Installation - -1. Clone the repo - ```sh - git clone https://github.com/ClaperCo/Claper.git - ``` -2. Install dependencies - ```sh - mix deps.get - ``` -3. Migrate your database - ```sh - mix ecto.migrate - ``` -4. Install JS dependencies - ```sh - cd assets && npm i - ``` -5. Allow execution of startup file - ```sh - chmod +x ./start.sh - ``` -6. Start Phoenix endpoint with - ```sh - ./start.sh - ``` - -Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. - -If you have configured `MAIL` to `local`, you can access to the mailbox at [`localhost:4000/dev/mailbox`](http://localhost:4000/dev/mailbox). - ## Contributing Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. @@ -108,7 +61,7 @@ Don't forget to give the project a star! Thanks again! 2. Create your Feature Branch (`git checkout -b feature/amazing_feature`) 3. Commit your Changes (`git commit -m 'Add some amazing feature'`) 4. Push to the Branch (`git push origin feature/amazing_feature`) -5. Open a Pull Request +5. Open a Pull Request on the `dev` branch diff --git a/compose.dev.yml b/compose.dev.yml new file mode 100644 index 0000000..6e72397 --- /dev/null +++ b/compose.dev.yml @@ -0,0 +1,45 @@ +services: + db: + image: postgres:15 + ports: + - 5432:5432 + volumes: + - "claper-db:/var/lib/postgresql/data" + healthcheck: + test: + - CMD + - pg_isready + - "-q" + - "-d" + - "claper" + - "-U" + - "claper" + retries: 3 + timeout: 5s + environment: + POSTGRES_PASSWORD: claper + POSTGRES_USER: claper + POSTGRES_DB: claper + networks: + - claper-dev + app: + build: + context: . + dockerfile: Dockerfile.dev + ports: + - 4000:4000 + volumes: + - ".:/app" + env_file: .env + depends_on: + - db + networks: + - claper-dev + +volumes: + claper-db: + driver: local + +networks: + claper-dev: + driver: bridge