DockerFile

This commit is contained in:
呱呱呱 2023-12-20 11:31:34 +08:00
parent d79213d14f
commit aecca87543
9 changed files with 135 additions and 34 deletions

3
.rubocop.yml Normal file
View File

@ -0,0 +1,3 @@
Layout/LineLength:
Max: 300

View File

@ -211,3 +211,5 @@ http://localhost:3000/
- [Git常用命令](https://git-scm.com/)
## 许可证协议

View File

@ -9,7 +9,7 @@ threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
port ENV.fetch("PORT") { 4000 }
# Specifies the `environment` that Puma will run in.
#

View File

@ -1,10 +1,10 @@
class AddUserLoginUniqIndex < ActiveRecord::Migration[5.2]
def change
users = User.group("login").having("count(1) >1")
ids = users.pluck(:id)
logins = users.pluck(:login)
User.where(login: logins).where.not(id: ids).destroy_all
# users = User.group("login").having("count(1) >1")
# ids = users.pluck(:id)
# logins = users.pluck(:login)
# User.where(login: logins).where.not(id: ids).destroy_all
remove_index :users, :login
add_index :users, :login, unique: true

View File

@ -1,38 +1,60 @@
version: '3'
services:
mysql:
image: mysql:5.7.17
command: --sql-mode=""
restart: always
volumes:
- ./mysql_data/:/var/lib/mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 123456789
MYSQL_DATABASE: educoder
redis:
image: redis:6.2.5
container_name: redis
image: redis:alpine
restart: always
ports:
- "6379:6379"
volumes:
- ./redis_data:/data
networks:
- default
- app_net
web:
image: gitlink-ubuntu18.04:latest
sidekiq:
env_file: .env
container_name: sidekiq
restart: always
build:
context: ../
dockerfile: Dockerfile
# command: bash -c "rm -f tmp/pids/server.pid && rails s -p 4000 -b '0.0.0.0'"
stdin_open: true
tty: true
volumes:
- .:/home/app/gitlink
ports:
- "4000:4000"
context: .
dockerfile: ./dockers/sidekiq/Dockerfile
depends_on:
- mysql
- redis
networks:
- default
- app_net
db:
image: mysql:5.7
container_name: mysql
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes:
- ./dockers/mysql/init:/docker-entrypoint-initdb.d
- /root/mysql/conf:/etc/mysql/conf.d
- /root/mysql/logs:/logs
- /root/data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: gitlinK#%01
ports:
- 3306:3306
networks:
- default
- app_net
app:
env_file: .env
container_name: forgeplus
restart: always
build:
context: .
dockerfile: ./dockers/app/Dockerfile
depends_on:
- sidekiq
- redis
- db
networks:
- default
- app_net
ports:
- 4000:4000
networks:
app_net:
external: true

38
docker-compose.yml.bank Normal file
View File

@ -0,0 +1,38 @@
version: '3'
services:
mysql:
image: mysql:5.7.17
command: --sql-mode=""
restart: always
volumes:
- ./mysql_data/:/var/lib/mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 123456789
MYSQL_DATABASE: educoder
redis:
image: redis:6.2.5
container_name: redis
restart: always
ports:
- "6379:6379"
volumes:
- ./redis_data:/data
web:
image: gitlink-ubuntu18.04:latest
build:
context: ../
dockerfile: Dockerfile
# command: bash -c "rm -f tmp/pids/server.pid && rails s -p 4000 -b '0.0.0.0'"
stdin_open: true
tty: true
volumes:
- .:/home/app/gitlink
ports:
- "4000:4000"
depends_on:
- mysql
- redis

14
dockers/app/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM ruby:2.6.2
RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list
RUN apt-get update -qq && apt-get install -y build-essential default-libmysqlclient-dev wkhtmltopdf libpng-dev libjpeg-dev libtiff-dev imagemagick nodejs
ENV TZ Asia/Shanghai
ENV RAILS_ROOT /var/www/forgeplus
RUN mkdir -p $RAILS_ROOT/tmp/pids
WORKDIR $RAILS_ROOT
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN gem install bundler:2.3.26
RUN bundle install --jobs 20 --retry 5 --without development test
COPY . .
EXPOSE 4000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

View File

@ -0,0 +1,9 @@
# create databases
CREATE DATABASE IF NOT EXISTS `testforgeplus`;
CREATE DATABASE IF NOT EXISTS `forge_test`;
CREATE DATABASE IF NOT EXISTS `forge_production`;
CREATE DATABASE IF NOT EXISTS `gitea_hat`;
# create root user and grant rights
CREATE USER 'root'@'localhost' IDENTIFIED BY 'local';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';

View File

@ -0,0 +1,13 @@
FROM ruby:2.6.2
RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list
RUN apt-get update -qq && apt-get install -y build-essential default-libmysqlclient-dev wkhtmltopdf libpng-dev libjpeg-dev libtiff-dev imagemagick nodejs
ENV TZ Asia/Shanghai
ENV RAILS_ROOT /var/www/forgeplus
RUN mkdir -p $RAILS_ROOT/tmp/pids
WORKDIR $RAILS_ROOT
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN gem install bundler:2.3.26
RUN bundle install --jobs 20 --retry 5 --without development test
COPY . .
CMD ["bundle", "exec", "sidekiq", "-C", "config/sidekiq.yml"]