diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..39a87c65 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,41 @@ +# Basis-Image für Ruby und Node.js +FROM ruby:3.3.4-alpine + +ENV APP_PATH=/var/app +ENV BUNDLE_VERSION=2.5.9 +ENV BUNDLE_PATH=/usr/local/bundle/gems +ENV TMP_PATH=/tmp/ +ENV RAILS_LOG_TO_STDOUT=true +ENV RAILS_PORT=3000 + +# Install dependencies for application +RUN apk -U add --no-cache \ + build-base \ + git \ + postgresql-dev \ + postgresql-client \ + libxml2-dev \ + libxslt-dev \ + nodejs \ + yarn \ + imagemagick \ + tzdata \ + less \ + yaml-dev \ + # gcompat for nokogiri on mac m1 + gcompat \ + && rm -rf /var/cache/apk/* \ + && mkdir -p $APP_PATH + +RUN gem update --system 3.5.7 && gem install bundler --version "$BUNDLE_VERSION" \ + && rm -rf $GEM_HOME/cache/* + +# FIXME It would be a good idea to use a other user than root, but this lead to permission error on export and maybe more yet. +# RUN adduser -D -h ${APP_PATH} vscode +USER root + +# Navigate to app directory +WORKDIR $APP_PATH + +EXPOSE $RAILS_PORT + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..8acaef4f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,17 @@ +{ + "name": "Ruby and Node DevContainer", + "dockerComposeFile": ["docker-compose.yml"], + "service": "dawarich_dev", + "settings": { + "terminal.integrated.defaultProfile.linux": "bash" + }, + "extensions": [ + "rebornix.ruby", // Ruby-Support + "esbenp.prettier-vscode", // Prettier for JS-Formating + "dbaeumer.vscode-eslint" // ESLint for JavaScript + ], + "postCreateCommand": "yarn install && bundle config set --local path 'vendor/bundle' && bundle install --jobs 20 --retry 5", + "forwardPorts": [3000], // Redirect to Rails-App-Server + "remoteUser": "root", + "workspaceFolder": "/var/app" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 00000000..5e2f006a --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,79 @@ +networks: + dawarich: +services: + dawarich_dev: + build: + context: . + dockerfile: Dockerfile + container_name: dawarich_dev + volumes: + - "${PWD}:/var/app:cached" + - dawarich_gem_cache_app:/usr/local/bundle/gems_app + - dawarich_public:/var/app/public + - dawarich_watched:/var/app/tmp/imports/watched + networks: + - dawarich + ports: + - 3000:3000 + - 9394:9394 + stdin_open: true + tty: true + environment: + RAILS_ENV: development + REDIS_URL: redis://dawarich_redis:6379/0 + DATABASE_HOST: dawarich_db + DATABASE_USERNAME: postgres + DATABASE_PASSWORD: password + DATABASE_NAME: dawarich_development + MIN_MINUTES_SPENT_IN_CITY: 60 + APPLICATION_HOST: localhost + APPLICATION_HOSTS: localhost + TIME_ZONE: Europe/London + APPLICATION_PROTOCOL: http + DISTANCE_UNIT: km + PHOTON_API_HOST: photon.komoot.io + PHOTON_API_USE_HTTPS: true + PROMETHEUS_EXPORTER_ENABLED: false + PROMETHEUS_EXPORTER_HOST: 0.0.0.0 + PROMETHEUS_EXPORTER_PORT: 9394 + ENABLE_TELEMETRY: false # More on telemetry: https://dawarich.app/docs/tutorials/telemetry + dawarich_redis: + image: redis:7.0-alpine + container_name: dawarich_redis + command: redis-server + networks: + - dawarich + volumes: + - dawarich_shared:/data + restart: always + healthcheck: + test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ] + interval: 10s + retries: 5 + start_period: 30s + timeout: 10s + dawarich_db: + image: postgres:14.2-alpine + container_name: dawarich_db + volumes: + - dawarich_db_data:/var/lib/postgresql/data + - dawarich_shared:/var/shared + networks: + - dawarich + restart: always + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U postgres -d dawarich_development" ] + interval: 10s + retries: 5 + start_period: 30s + timeout: 10s + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password +volumes: + dawarich_db_data: + dawarich_gem_cache_app: + dawarich_gem_cache_sidekiq: + dawarich_shared: + dawarich_public: + dawarich_watched: diff --git a/.gitignore b/.gitignore index d53fcdf6..b3803267 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,12 @@ !/app/assets/builds/.keep .DS_Store .env + +.devcontainer/.onCreateCommandMarker +.devcontainer/.postCreateCommandMarker +.devcontainer/.updateContentCommandMarker + +.vscode-server/ +.ash_history +.cache/ +.dotnet/ diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 00000000..8b1b6a97 --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,21 @@ +If you want to develop with dawarich you can use the devcontainer, with your IDE. It is tested with visual studio code. + +Load the directory in Vs-Code and press F1. And Run the command: `Dev Containers: Rebuild Containers` after a while you should see a terminal. + +Now you can create/prepare the Database (this need to be done once): +```bash +bundle exec rails db:prepare +``` + +Afterwards you can run sidekiq: +```bash +bundle exec sidekiq + +``` + +And in a second terminal the dawarich-app: +```bash +bundle exec bin/dev +``` + +You can connect with a web browser to http://127.0.0.l:3000/ and login with the default credentials.