Skip to content
Open
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
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ruby:3.1.2

# Set up the working directory
WORKDIR /app

# Install dependencies
COPY Gemfile Gemfile.lock ./
RUN bundle install

# Copy the application code
COPY . .

# Expose port
EXPOSE 3000
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ GEM
nio4r (2.7.3)
nokogiri (1.16.7-x64-mingw-ucrt)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
pg (1.5.8)
pg (1.5.8-x64-mingw-ucrt)
puma (5.6.8)
nio4r (~> 2.0)
Expand Down Expand Up @@ -173,6 +176,7 @@ GEM

PLATFORMS
x64-mingw-ucrt
x86_64-linux

DEPENDENCIES
bcrypt (~> 3.1.7)
Expand Down
7 changes: 0 additions & 7 deletions app/sidekiq/delete_old_posts_job.rb

This file was deleted.

Empty file added backup.sql
Empty file.
95 changes: 22 additions & 73 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,88 +1,37 @@
# PostgreSQL. Versions 9.3 and up are supported.
#
# Install the pg driver:
# gem install pg
# On macOS with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On macOS with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem "pg"
#


default: &default

#adapter: postgresql
#encoding: unicode
#pool: 5
#host: db #<%= ENV['DB_HOST'] || 'localhost' %>
#port: 5432
#username: postgres
#password: 1234
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: postgres
password: 1234
host: localhost
pool: 5
host: <%= ENV['DB_HOST'] || 'db' %>
port: <%= ENV['DB_PORT'] || 5432 %>
username: <%= ENV['DB_USERNAME'] || 'postgres' %>
password: <%= ENV['DB_PASSWORD'] || '1234' %>

development:
<<: *default
database: project_api_development

# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
# When left blank, postgres will use the default role. This is
# the same name as the operating system user running Rails.


# The password associated with the postgres role (username).


# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.


# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
#port: 5432

# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public

# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# Defaults to warning.
#min_messages: notice

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.

test:
<<: *default
database: project_api_test

# As with config/credentials.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password or a full connection URL as an environment
# variable when you boot the app. For example:
#
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# If the connection URL is provided in the special DATABASE_URL environment
# variable, Rails will automatically merge its configuration values on top of
# the values provided in this file. Alternatively, you can specify a connection
# URL environment variable explicitly:
#
# production:
# url: <%= ENV["MY_APP_DATABASE_URL"] %>
#
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full overview on how database connection configuration can be specified.
#

production:
<<: *default
database: project_api_production
username: project_api
#username: project_api
#password: <%= ENV["PROJECT_API_DATABASE_PASSWORD"] %>
username: <%= ENV["PROJECT_API_DATABASE_USERNAME"] %>
password: <%= ENV["PROJECT_API_DATABASE_PASSWORD"] %>

12 changes: 11 additions & 1 deletion config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
=begin
Sidekiq.configure_server do |config|
config.redis = { url: 'redis://localhost:6379/1' }
end

Sidekiq.configure_client do |config|
config.redis = { url: 'redis://localhost:6379/1' }
end


=end

Sidekiq.configure_server do |config|
config.redis = { url: 'redis://redis:6379/1' }
end

Sidekiq.configure_client do |config|
config.redis = { url: 'redis://redis:6379/1' }
end
14 changes: 7 additions & 7 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# Character.create(name: "Luke", movie: movies.first)

# db/seeds.rb
User.create(name: 'John Doe', email: 'john@example.com', password: 'password', image: 'photo.png');
User.create(name: 'moamen', email: 'moamen@example.com', password: 'password', image: 'photo.png');



52 changes: 52 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

services:
db:
image: postgres:17rc1 # Use 'latest' or a valid version like '15'
volumes:
# - ./tmp/db:/var/lib/postgresql/data
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 1234
POSTGRES_DB: project_api_development

redis:
image: redis:7
ports:
- "6379:6379"

web:
build:
context: .
dockerfile: Dockerfile
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -b '0.0.0.0'"
volumes:
- .:/app
ports:
- "3000:3000"
environment:
DATABASE_URL: postgres://postgres:1234@db:5432/project_api_development
REDIS_URL: redis://redis:6379/1
#new
DB_HOST: db
DB_PORT: 5432
#
DB_USERNAME: postgres
DB_PASSWORD: 1234
depends_on:
- db
- redis

sidekiq:
build:
context: .
dockerfile: Dockerfile
command: bundle exec sidekiq
volumes:
- .:/app
depends_on:
- db
- redis

volumes:
db_data:
1 change: 1 addition & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@