docker部署整理
This commit is contained in:
parent
b66293b044
commit
2c5c03f77c
36
Dockerfile
36
Dockerfile
|
@ -1,34 +1,8 @@
|
||||||
FROM ubuntu:20.04
|
FROM registry.cn-hangzhou.aliyuncs.com/gitlink/ruby:2.4.5
|
||||||
RUN apt-get update
|
|
||||||
|
|
||||||
RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata
|
ADD ./ /home/pdl/gitlink
|
||||||
# basics
|
|
||||||
RUN apt-get install -y libssl-dev curl libmysqlclient-dev imagemagick nodejs mysql-server redis-server
|
|
||||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
|
||||||
# confirm openssl version
|
|
||||||
RUN openssl version
|
|
||||||
RUN which openssl
|
|
||||||
# install RVM, Ruby, and Bundler
|
|
||||||
RUN \curl -L https://get.rvm.io | bash -s stable
|
|
||||||
# rvm environment variable
|
|
||||||
RUN /bin/bash -l -c "source /etc/profile.d/rvm.sh"
|
|
||||||
RUN /bin/bash -l -c "rvm requirements"
|
|
||||||
# replace ruby mirror url, accelerate install ruby
|
|
||||||
RUN sed -i 's/rvm_remote_server_url2/#rvm_remote_server_url2/g' /usr/local/rvm/config/db
|
|
||||||
RUN sed -i 's/cache.ruby-lang.org/cache.ruby-china.com/g' /usr/local/rvm/config/db
|
|
||||||
# install ruby
|
|
||||||
RUN /bin/bash -l -c "rvm install 2.4.5"
|
|
||||||
# confirm ruby version
|
|
||||||
RUN /bin/bash -l -c "rvm list"
|
|
||||||
RUN /bin/bash -l -c "ruby -v"
|
|
||||||
|
|
||||||
#RUN apt-get install -y nodejs
|
WORKDIR /home/pdl/gitlink
|
||||||
|
|
||||||
WORKDIR /home/app/gitlink
|
|
||||||
|
|
||||||
ADD ./ /home/app/gitlink
|
|
||||||
|
|
||||||
RUN cd /home/app/gitlink
|
|
||||||
|
|
||||||
RUN /bin/bash -l -c 'gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/'
|
RUN /bin/bash -l -c 'gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/'
|
||||||
|
|
||||||
|
@ -36,7 +10,6 @@ RUN /bin/bash -l -c 'gem update --system'
|
||||||
|
|
||||||
RUN /bin/bash -l -c 'gem install bundler -v 2.3.26'
|
RUN /bin/bash -l -c 'gem install bundler -v 2.3.26'
|
||||||
RUN /bin/bash -l -c 'gem install rake'
|
RUN /bin/bash -l -c 'gem install rake'
|
||||||
RUN /bin/bash -l -c 'gem install puma -v 5.6.5'
|
|
||||||
|
|
||||||
RUN rm -rf Gemfile.lock
|
RUN rm -rf Gemfile.lock
|
||||||
|
|
||||||
|
@ -46,6 +19,9 @@ RUN touch config/redis.yml
|
||||||
RUN touch config/elasticsearch.yml
|
RUN touch config/elasticsearch.yml
|
||||||
|
|
||||||
RUN /bin/bash -l -c 'bundle install'
|
RUN /bin/bash -l -c 'bundle install'
|
||||||
|
RUN /bin/bash -l -c 'RAILS_ENV=production rails db:create'
|
||||||
|
RUN /bin/bash -l -c 'RAILS_ENV=production bundle exec rake sync_table_structure:import_csv'
|
||||||
|
RUN /bin/bash -l -c 'RAILS_ENV=production rails db:migrate'
|
||||||
|
|
||||||
#EXPOSE 4000
|
#EXPOSE 4000
|
||||||
#RUN /bin/bash -l -c 'RAILS_ENV=production puma'
|
#RUN /bin/bash -l -c 'RAILS_ENV=production puma'
|
|
@ -23,9 +23,9 @@ default: &default
|
||||||
redirect_uri: 'https://test.a.com/api/auth/educoder/callback'
|
redirect_uri: 'https://test.a.com/api/auth/educoder/callback'
|
||||||
|
|
||||||
gitea:
|
gitea:
|
||||||
access_key_id: ''
|
access_key_id: <%= ENV.fetch("GITEA_USER") { 'root' } %>
|
||||||
access_key_secret: ''
|
access_key_secret: <%= ENV.fetch("GITEA_PWD") { '123456' } %>
|
||||||
domain: 'https://testgit.trustie.net'
|
domain: <%= ENV.fetch("GITEA_URL") { 'http://gitea:3000' } %>
|
||||||
base_url: '/api/v1'
|
base_url: '/api/v1'
|
||||||
admin_token: '123123'
|
admin_token: '123123'
|
||||||
hat_base_url: '/api/hat'
|
hat_base_url: '/api/hat'
|
||||||
|
|
|
@ -1,62 +1,29 @@
|
||||||
# MySQL. Versions 5.1.10 and up are supported.
|
|
||||||
#
|
|
||||||
# Install the MySQL driver
|
|
||||||
# gem install mysql2
|
|
||||||
#
|
|
||||||
# Ensure the MySQL gem is defined in your Gemfile
|
|
||||||
# gem 'mysql2'
|
|
||||||
#
|
|
||||||
# And be sure to use new-style password hashing:
|
|
||||||
# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html
|
|
||||||
#
|
|
||||||
default: &default
|
default: &default
|
||||||
adapter: mysql2
|
adapter: mysql2
|
||||||
host: 127.0.0.1
|
host: <%= ENV.fetch("MYSQL_HOST") { '127.0.0.1' } %>
|
||||||
encoding: utf8mb4
|
encoding: utf8mb4
|
||||||
reconnect: true
|
reconnect: true
|
||||||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 20 } %>
|
||||||
username: root
|
username: <%= ENV.fetch("MYSQL_USER") { 'root' } %>
|
||||||
password: 123456
|
password: <%= ENV.fetch("MYSQL_PWD") { '123456' } %>
|
||||||
# socket: /var/run/mysqld/mysqld.sock
|
wait_timeout: 10
|
||||||
gitea_server:
|
gitea_server:
|
||||||
adapter: mysql2
|
adapter: mysql2
|
||||||
database: gitea_development
|
database: <%= ENV.fetch("MYSQL_DB_GITEA") { 'gitea' } %>
|
||||||
host: 127.0.0.1
|
host: <%= ENV.fetch("MYSQL_HOST") { '127.0.0.1' } %>
|
||||||
username: root
|
username: <%= ENV.fetch("MYSQL_USER") { 'root' } %>
|
||||||
password: "123456"
|
password: <%= ENV.fetch("MYSQL_PWD") { '123456' } %>
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
database: forge_development
|
database: forgeplus_development
|
||||||
|
|
||||||
# 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:
|
test:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: forge_test
|
database: forgeplus_test
|
||||||
|
|
||||||
# As with config/secrets.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 as a unix environment variable when you boot
|
|
||||||
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
|
|
||||||
# for a full rundown on how to provide these environment variables in a
|
|
||||||
# production deployment.
|
|
||||||
#
|
|
||||||
# On Heroku and other platform providers, you may have a full connection URL
|
|
||||||
# available as an environment variable. For example:
|
|
||||||
#
|
|
||||||
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
|
|
||||||
#
|
|
||||||
# You can use this database configuration with:
|
|
||||||
#
|
|
||||||
# production:
|
|
||||||
# url: <%= ENV['DATABASE_URL'] %>
|
|
||||||
#
|
|
||||||
production:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: forge_production
|
database: <%= ENV.fetch("MYSQL_DB") { 'forgeplus' } %>
|
||||||
|
|
|
@ -1,38 +1,69 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
gitlink:
|
||||||
|
external: false
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:5.7.17
|
image: mysql:5.7.17
|
||||||
command: --sql-mode=""
|
command: --sql-mode=""
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./mysql_data/:/var/lib/mysql
|
- ./mysql:/var/lib/mysql
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "13306:3306"
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: 123456789
|
- MYSQL_ROOT_PASSWORD=gitea
|
||||||
MYSQL_DATABASE: educoder
|
- MYSQL_USER=gitea
|
||||||
|
- MYSQL_PASSWORD=gitea
|
||||||
|
- MYSQL_DATABASE=gitea
|
||||||
|
networks:
|
||||||
|
- gitlink
|
||||||
|
|
||||||
redis:
|
gitea:
|
||||||
image: redis:6.2.5
|
image: registry.cn-hangzhou.aliyuncs.com/gitlink/gitea_hat:latest
|
||||||
container_name: redis
|
container_name: gitea
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- "3000:3000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./redis_data:/data
|
- ./gitea/app.ini:/etc/gitea/app.ini
|
||||||
|
- ./gitea/start.sh:/start.sh
|
||||||
|
- /data/repositories:/data/repositories
|
||||||
|
command:
|
||||||
|
- bash /start.sh
|
||||||
|
- gitea admin user create --username root --password gitlink#2023 --email root@example.org --config /etc/gitea/app.ini
|
||||||
|
environment:
|
||||||
|
- GITEA_WORK_DIR = /var/lib/gitea
|
||||||
|
- GITEA__database__DB_TYPE=mysql
|
||||||
|
- GITEA__database__HOST=mysql:3306
|
||||||
|
- GITEA__database__NAME=gitea
|
||||||
|
- GITEA__database__USER=gitea
|
||||||
|
- GITEA__database__PASSWD=gitea
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
networks:
|
||||||
|
- gitlink
|
||||||
|
|
||||||
web:
|
web:
|
||||||
image: gitlink-ubuntu18.04:latest
|
image: gitlink-ubuntu20.04:latest
|
||||||
build:
|
build:
|
||||||
context: ../
|
context: ../
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
# command: bash -c "rm -f tmp/pids/server.pid && rails s -p 4000 -b '0.0.0.0'"
|
environment:
|
||||||
|
- MYSQL_USER=root
|
||||||
|
- MYSQL_PWD=gitea
|
||||||
|
- MYSQL_HOST=mysql
|
||||||
|
- GITEA_USER=root
|
||||||
|
- GITEA_PWD=gitlink#2023
|
||||||
|
- GITEA_URL=gitea
|
||||||
|
command: bash -c "cmd /home/pdl/forgeplus && rm -f tmp/pids/server.pid && rails s -p 4000 -b '0.0.0.0'"
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
volumes:
|
# volumes:
|
||||||
- .:/home/app/gitlink
|
# - .:/home/app/gitlink
|
||||||
ports:
|
ports:
|
||||||
- "4000:4000"
|
- "4000:4000"
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql
|
- mysql
|
||||||
- redis
|
- gitea
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
APP_NAME = 开源项目托管
|
||||||
|
RUN_USER = root
|
||||||
|
RUN_MODE = prod
|
||||||
|
I_AM_BEING_UNSAFE_RUNNING_AS_ROOT = true
|
||||||
|
[oauth2]
|
||||||
|
JWT_SECRET = pyD-ZA6zwykBhVCWdF5FsdRGDtM6kg16JLhcCu8uLPM
|
||||||
|
[security]
|
||||||
|
INTERNAL_TOKEN = eyDDbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1NzQyMzU3OTN9.w7RDQaNanZHdC2XIrr9kAntPIjhfkXXOiBnNTbEdqQ8
|
||||||
|
INSTALL_LOCK = true
|
||||||
|
SECRET_KEY = K4DDaucPzKQnTf7WQxKFIoFNtIlsWVacoN5Ss3VDypQBUes7Ncy96UU735sfGOar
|
||||||
|
PASSWORD_COMPLEXITY = off
|
||||||
|
[database]
|
||||||
|
DB_TYPE = mysql
|
||||||
|
HOST = mysql:3306
|
||||||
|
NAME = gitea
|
||||||
|
USER = root
|
||||||
|
PASSWD = `gitea`
|
||||||
|
CHARSET = utf8
|
||||||
|
SSL_MODE = disable
|
||||||
|
#PATH = /var/lib/gitea/gitea.db
|
||||||
|
PATH =/var/lib/gitea/data/gitea.db
|
||||||
|
|
||||||
|
[repository]
|
||||||
|
ROOT = /data/repositories
|
||||||
|
|
||||||
|
[lfs]
|
||||||
|
PATH = /data/gitea/data/lfs
|
||||||
|
|
||||||
|
[server]
|
||||||
|
SSH_DOMAIN = 106.75.10.84
|
||||||
|
DOMAIN = 106.75.10.84
|
||||||
|
ROOT_URL = http://106.75.10.84:3000/
|
||||||
|
DISABLE_SSH = false
|
||||||
|
SSH_PORT = 22
|
||||||
|
LFS_START_SERVER = true
|
||||||
|
;LFS_CONTENT_PATH = /data/gitea/data/lfs
|
||||||
|
LFS_JWT_SECRET = n2kib4qdArULO57JW0jD2Ygm3z1ehzI8Y4zVfbxouyY
|
||||||
|
OFFLINE_MODE = false
|
||||||
|
[mailer]
|
||||||
|
ENABLED = false
|
||||||
|
[service]
|
||||||
|
REGISTER_EMAIL_CONFIRM = false
|
||||||
|
ENABLE_NOTIFY_MAIL = false
|
||||||
|
DISABLE_REGISTRATION = false
|
||||||
|
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
|
||||||
|
ENABLE_CAPTCHA = false
|
||||||
|
REQUIRE_SIGNIN_VIEW = false
|
||||||
|
DEFAULT_KEEP_EMAIL_PRIVATE = false
|
||||||
|
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
|
||||||
|
DEFAULT_ENABLE_TIMETRACKING = true
|
||||||
|
NO_REPLY_ADDRESS = noreply.example.org
|
||||||
|
SHOW_REGISTRATION_BUTTON = false
|
||||||
|
|
||||||
|
[picture]
|
||||||
|
DISABLE_GRAVATAR = false
|
||||||
|
ENABLE_FEDERATED_AVATAR = true
|
||||||
|
[openid]
|
||||||
|
ENABLE_OPENID_SIGNIN = true
|
||||||
|
ENABLE_OPENID_SIGNUP = true
|
||||||
|
[session]
|
||||||
|
PROVIDER = file
|
||||||
|
[log]
|
||||||
|
MODE = file
|
||||||
|
LEVEL = info
|
||||||
|
ROUTER = console
|
||||||
|
ROOT_PATH = /var/lib/gitea/log
|
||||||
|
[api]
|
||||||
|
DEFAULT_PAGING_NUM = 20
|
||||||
|
MAX_RESPONSE_ITEMS = 200
|
||||||
|
|
||||||
|
[git]
|
||||||
|
PATH =
|
||||||
|
DISABLE_DIFF_HIGHLIGHT = false
|
||||||
|
MAX_GIT_DIFF_LINES = 1000
|
||||||
|
MAX_GIT_DIFF_LINE_CHARACTERS = 5000
|
||||||
|
MAX_GIT_DIFF_FILES = 100
|
||||||
|
GC_ARGS =
|
||||||
|
EnableAutoGitWireProtocol = true
|
||||||
|
COMMITS_RANGE_SIZE = 50
|
||||||
|
|
||||||
|
; Operation timeout in seconds
|
||||||
|
[git.timeout]
|
||||||
|
DEFAULT = 1800
|
||||||
|
MIGRATE = 21600
|
||||||
|
MIRROR = 1800
|
||||||
|
CLONE = 1800
|
||||||
|
PULL = 1800
|
||||||
|
GC = 60
|
||||||
|
|
||||||
|
[migrations]
|
||||||
|
ALLOW_LOCALNETWORKS = true
|
||||||
|
|
||||||
|
[cron.update_mirrors]
|
||||||
|
SCHEDULE = @every 24h
|
||||||
|
|
||||||
|
[cron.delete_repo_archives]
|
||||||
|
ENABLED = true
|
||||||
|
RUN_AT_START = true
|
||||||
|
SCHEDULE = @every 72h
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
cp /gitea_hat/gitea_hat /usr/local/bin/gitea
|
||||||
|
/usr/local/bin/gitea web --config /etc/gitea/app.ini
|
Loading…
Reference in New Issue