forked from scisco/canvas-lms-docker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
143 lines (120 loc) · 5.34 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#Download base image ubuntu 20.04
FROM ubuntu:20.04
# LABEL about the custom image
LABEL maintainer="[email protected]"
LABEL version="0.1"
LABEL description="This is custom Docker Image for Canvas LMS."
# Get rid of the ugly errors
ENV DEBIAN_FRONTEND=noninteractive
# Update Ubuntu software repository and install dependencies
RUN apt-get update -y && apt-get install -y gnupg2 dirmngr
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
RUN apt-get update -y && apt-get install -y nano wget curl libapache2-mod-passenger apache2 python software-properties-common apt-transport-https ca-certificates ssmtp pwgen
# Install Redis
RUN add-apt-repository ppa:chris-lea/redis-server
RUN apt-get update -y && apt-get install -y redis-server
# Install Node.js
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs
# Get postgresql and configure the user and database
RUN apt-get install -y postgresql
RUN pg_ctlcluster 12 main start
USER postgres
RUN /etc/init.d/postgresql start &&\
createuser canvas --no-createdb --no-superuser --no-createrole &&\
createdb canvas_production --owner=canvas &&\
psql -c "alter user canvas password 'canvas';" &&\
createuser root &&\
psql -c "alter user root with superuser" postgres
# Get git-core, download Canvas and install
USER root
RUN apt-get install -y git-core
RUN cd /var && git clone --branch stable https://github.com/instructure/canvas-lms.git canvas
WORKDIR /var/canvas
# Install Ruby libraries and packages that Canvas needs
RUN add-apt-repository ppa:brightbox/ruby-ng
RUN apt-get update -y
RUN apt-get install -y ruby2.6 ruby2.6-dev zlib1g-dev libxml2-dev \
libsqlite3-dev libpq-dev \
libxmlsec1-dev make g++
# Install Bundler
RUN gem install bundler --version 2.2.19
RUN bundle _2.2.19_ install --without pulsar --path vendor/bundle
# Install Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -y && apt-get install -y yarn=1.19.1-1
# Install Passenger
RUN sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger focal main > /etc/apt/sources.list.d/passenger.list'
RUN apt-get update -y && apt-get install -y passenger
# Enable rewrite and passenger on Apache
RUN a2enmod rewrite
RUN a2enmod passenger
RUN a2enmod ssl
# Setup automation jobs
RUN ln -s /var/canvas/script/canvas_init /etc/init.d/canvas_init
RUN update-rc.d canvas_init defaults
# Copy the sample config files, override with our own for certain cases
RUN for config in amazon_s3 database \
delayed_jobs domain file_store outgoing_mail security external_migration; \
do cp config/$config.yml.example config/$config.yml; done
# Create all Canvas required assets
RUN mkdir -p log tmp/pids public/assets app/stylesheets/brandable_css_brands
RUN touch app/stylesheets/_brandable_variables_defaults_autogenerated.scss
RUN touch Gemfile.lock
RUN touch log/production.log
RUN adduser --disabled-password --gecos canvas canvasuser
RUN chown -R canvasuser config/environment.rb log tmp public/assets \
app/stylesheets/_brandable_variables_defaults_autogenerated.scss \
app/stylesheets/brandable_css_brands Gemfile.lock config.ru
RUN yarn install
ENV CANVAS_BUILD_CONCURRENCY=1
ENV RAILS_ENV=production
RUN locale-gen en_US.UTF-8
RUN dpkg-reconfigure locales
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN bundle exec rake --trace canvas:compile_assets
RUN chown -R canvasuser public/dist/brandable_css
# Expose HTTP, HTTPS and POSTGRES ports
EXPOSE 80
RUN unlink /etc/apache2/sites-enabled/000-default.conf
# Add all necessary permissions
RUN chown canvasuser config/*.yml && chmod 400 config/*.yml
# Copy all premade config files and add their example ENV vars
COPY ./start.sh /var/canvas/start.sh
RUN chmod +x /var/canvas/start.sh
COPY ./config/database.yml /var/canvas/config/database.yml
COPY ./config/domain.yml /var/canvas/config/domain.yml
COPY ./config/security.yml /var/canvas/config/security.yml
COPY ./config/outgoing_mail.yml /var/canvas/config/outgoing_mail.yml
COPY ./config/redis.yml /var/canvas/config/redis.yml
COPY ./config/cache_store.yml /var/canvas/config/cache_store.yml
COPY ./config/amazon_s3.yml /var/canvas/config/amazon_s3.yml
COPY ./config/file_store.yml /var/canvas/config/file_store.yml
COPY ./overrides/big_blue_button_conference.rb /var/canvas/app/models/big_blue_button_conference.rb
COPY ./overrides/conferences_controller.rb /var/canvas/app/controllers/conferences_controller.rb
COPY ./config/canvas_no_ssl.conf /etc/apache2/sites-enabled/canvas.conf
COPY ./config/ssmtp.conf /etc/ssmtp/ssmtp.conf
ENV DOMAIN=www.example.com
ENV CANVAS_LMS_ACCOUNT_NAME=admin
ENV CANVAS_LMS_ADMIN_PASSWORD=REPLACEME
ENV EMAIL_DOMAIN=example.com
ENV EMAIL_FROM="Instructure Canvas"
ENV ENCRYPTION_KEY=REPLACEME
ENV AWS_BUCKET_NAME=REPLACEME
ENV AWS_ACCESS_KEY_ID=REPLACEME
ENV AWS_SECRET_ACCESS_KEY=REPLACEME
ENV DATABASE_NAME=canvas_production
ENV DATABASE_NAME_QUEUE=canvas_queue_production
ENV DATABASE_HOST=localhost
ENV DATABASE_USERNAME=canvas
ENV DATABASE_PASSWORD='canvas'
ENV CUSTOM_PORT=''
ENV CANVAS_LMS_STATS_COLLECTION=anonymized
ENV EMAIL_ADDRESS=172.17.0.1
ENV EMAIL_PORT=25
ENTRYPOINT ["bash", "/var/canvas/start.sh"]