Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM ruby:3.3.5
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client graphviz
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
Expand Down
98 changes: 8 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ProGeSer API
# Uniser API

[![Build Status](https://travis-ci.org/Progeser/progeser-api.svg?branch=master)](https://travis-ci.org/Progeser/progeser-api)
[![Dependabot](https://api.dependabot.com/badges/status?host=github&repo=Progeser/progeser-api)](https://api.dependabot.com/badges/status?host=github&repo=Progeser/progeser-api)
Expand All @@ -10,7 +10,7 @@
# Presentation

ProGeSer API is part of the ProGeSer project, an application to manage greenhouses.
You can find the front part [here](https://github.com/Progeser/progeser-front).
You can find the front part [here](https://github.com/Progeser/progeser-front-rework).

# Run the application

Expand All @@ -19,9 +19,9 @@ You can run the application in 2 ways.
## With Ruby

### Requirements
* Ruby v 2.6.5
* Bundler v. >= 1.2.0, < 3
* Postgresql v. 10
* Ruby v 3.3.5
* Bundler v. >= 2.5.18
* Postgresql v. 15.0.0

### How to run

Expand Down Expand Up @@ -61,8 +61,8 @@ To run integration tests, run the following:

### Requirements

* Docker v. >=17.0.3
* Docker Compose v. >= 1.20.0
* Docker v. >=24.0.7
* Docker Compose v. >= 2.23.0

### How to run

Expand All @@ -84,86 +84,4 @@ http://localhost:3000

To see the endpoints documentation, you can go to:

http://localhost:3000/apidoc

# Deploy the full application

You only need docker-compose to run the full application, and a .env file.

First, create a docker-compose.yml file to deploy the full application:

```Dockerfile
version: '3.6'

services:
db:
restart: unless-stopped
networks:
- progeser-network
image: postgres:10
environment:
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- db_data:/var/lib/postgresql/data

redis:
restart: unless-stopped
networks:
- progeser-network
image: redis:5.0.7

web:
restart: unless-stopped
networks:
- progeser-network
image: progeser/progeser-api-web
ports:
- "3000:3000"
env_file: .env
environment:
RAILS_ENV: development
depends_on:
- db
- redis

sidekiq:
restart: unless-stopped
networks:
- progeser-network
image: progeser/progeser-api-sidekiq
depends_on:
- web
- db
- redis
env_file: .env
environment:
RAILS_ENV: development

front:
restart: unless-stopped
image: progeser/progeser-front-dev
ports:
- "8888:80"

networks:
progeser-network:
driver: bridge

volumes:
db_data:
```
Then, create a .env file. You can find an exemple [here](https://github.com/Progeser/progeser-api/blob/master/.env.example).

Finally, run the following :

`docker-compose run -d`

To populate database and some fake data, run the following:

`docker-compose run web bundle exec rake db:create`

`docker-compose run web bundle exec rake db:migrate`

`docker-compose run web bundle exec rake db:seed`

You can now navigate to http://localhost:8888
http://localhost:3000/apidoc
62 changes: 14 additions & 48 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,29 @@
version: '3.6'
version: '3.9'

services:
db:
restart: unless-stopped
networks:
- test-network
image: postgres:10
image: postgres:15
container_name: rails_db
environment:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
volumes:
- db_data:/var/lib/postgresql/data

redis:
restart: unless-stopped
networks:
- test-network
image: redis:5.0.7
restart: always

web:
restart: unless-stopped
networks:
- test-network
build: .
volumes:
- .:/myapp
- gem_cache:/usr/local/bundle/gems
- node_modules:/app/node_modules
build:
context: .
container_name: rails_app
environment:
DATABASE_HOST: db
DATABASE_USER: postgres
DATABASE_PASSWORD: password
ports:
- "3000:3000"
env_file: .env
environment:
RAILS_ENV: development
depends_on:
- db
- redis

sidekiq:
restart: unless-stopped
networks:
- test-network
build: .
depends_on:
- web
- db
- redis
volumes:
- .:/app
- gem_cache:/usr/local/bundle/gems
- node_modules:/app/node_modules
env_file: .env
environment:
RAILS_ENV: development
entrypoint: ./entrypoints/sidekiq-entrypoint.sh

networks:
test-network:
driver: bridge
restart: always

volumes:
gem_cache:
db_data:
node_modules:
2 changes: 1 addition & 1 deletion entrypoints/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ if [ -f tmp/pids/server.pid ]; then
rm tmp/pids/server.pid
fi

bundle exec rails s -b 0.0.0.0
bundle exec rails db:create db:migrate db:seed && bundle exec rails s -b 0.0.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

le db:create et db:seed ne sont généralement qu'à exécuter une seule fois, lors du tout premier déploiement de l'application ; pas sûr qu'il faille le mettre dans le entrypoint générique qui sera lu à chaque redéploiement

Loading