Skip to content
Snippets Groups Projects
Commit 4d086abe authored by Ismael Posada Trobo's avatar Ismael Posada Trobo
Browse files

Move precompile assets to running time, due to...

parent 1af65e7a
No related branches found
No related tags found
No related merge requests found
......@@ -69,51 +69,40 @@ WORKDIR $HOME
### Plugins
#
# - OAuth
RUN git clone --depth=1 https://github.com/discourse/discourse-oauth2-basic.git /discourse/plugins/discourse-oauth2-basic
RUN \
git clone --depth=1 https://github.com/discourse/discourse-oauth2-basic.git /discourse/plugins/discourse-oauth2-basic && \
# - Chat Integration
RUN git clone --depth=1 https://github.com/discourse/discourse-chat-integration.git /discourse/plugins/discourse-chat-integration
git clone --depth=1 https://github.com/discourse/discourse-chat-integration.git /discourse/plugins/discourse-chat-integration && \
# - Discourse Solved
RUN git clone --depth=1 https://github.com/discourse/discourse-solved.git /discourse/plugins/discourse-solved
git clone --depth=1 https://github.com/discourse/discourse-solved.git /discourse/plugins/discourse-solved && \
# - Trade buttons (used on Marketplace)
RUN git clone --depth=1 https://github.com/jannolii/discourse-topic-trade-buttons.git /discourse/plugins/discourse-topic-trade-buttons
git clone --depth=1 https://github.com/jannolii/discourse-topic-trade-buttons.git /discourse/plugins/discourse-topic-trade-buttons && \
# - Saved Searches
RUN git clone --depth=1 https://github.com/discourse/discourse-saved-searches.git /discourse/plugins/discourse-saved-searches
git clone --depth=1 https://github.com/discourse/discourse-saved-searches.git /discourse/plugins/discourse-saved-searches && \
# - Migrate Password
RUN git clone --depth=1 https://github.com/discoursehosting/discourse-migratepassword.git /discourse/plugins/discourse-migratepassword
git clone --depth=1 https://github.com/discoursehosting/discourse-migratepassword.git /discourse/plugins/discourse-migratepassword && \
# - Discourse Math
RUN git clone --depth=1 https://github.com/discourse/discourse-math.git /discourse/plugins/discourse-math
git clone --depth=1 https://github.com/discourse/discourse-math.git /discourse/plugins/discourse-math && \
# - Discourse Askimet
RUN git clone --depth=1 https://github.com/discourse/discourse-akismet.git /discourse/plugins/discourse-akismet
git clone --depth=1 https://github.com/discourse/discourse-akismet.git /discourse/plugins/discourse-akismet && \
# - Canned replies
RUN git clone --depth=1 https://github.com/discourse/discourse-canned-replies.git /discourse/plugins/discourse-canned-replies
git clone --depth=1 https://github.com/discourse/discourse-canned-replies.git /discourse/plugins/discourse-canned-replies && \
# - Discourse JIRA
RUN git clone --depth=1 https://github.com/karies/discourse-jira.git /discourse/plugins/discourse-jira
git clone --depth=1 https://github.com/karies/discourse-jira.git /discourse/plugins/discourse-jira && \
# - Prometheus
RUN git clone --depth=1 https://github.com/discourse/discourse-prometheus.git /discourse/plugins/discourse-prometheus
git clone --depth=1 https://github.com/discourse/discourse-prometheus.git /discourse/plugins/discourse-prometheus && \
# - Calendar
RUN git clone --depth=1 https://github.com/discourse/discourse-calendar.git /discourse/plugins/discourse-calendar
git clone --depth=1 https://github.com/discourse/discourse-calendar.git /discourse/plugins/discourse-calendar && \
# - Assign
RUN git clone --depth=1 https://github.com/discourse/discourse-assign.git /discourse/plugins/discourse-assign
git clone --depth=1 https://github.com/discourse/discourse-assign.git /discourse/plugins/discourse-assign
### Gem installation
RUN exec bundle install --deployment --jobs 4 --without test --without development && \
exec bundle exec rake maxminddb:get && \
find /discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +
COPY ["cgroup-limits","init-assets.sh","init-dbmigration.sh","run-discourse.sh","run-nginx.sh","run-redis.sh","./"]
RUN chmod +x ./run-discourse.sh ./run-nginx.sh ./run-redis.sh ./init-assets.sh ./init-dbmigration.sh && \
COPY ["cgroup-limits","init-dbmigration.sh","run-discourse.sh","run-nginx.sh","run-redis.sh","./"]
RUN chmod +x ./run-discourse.sh ./run-nginx.sh ./run-redis.sh ./init-dbmigration.sh && \
chgrp -R 0 /discourse && chmod -R g=u /discourse && \
chmod +x /discourse/config/unicorn_launcher
......
#!/bin/bash
# Replace environment variables
# This is mandatory as at the time of doing the migration, discourse needs to know redis IP,
# which is set thanks to discourse.conf file.
echo "--> Overwritting env variables ..."
envsubst < /tmp/discourse-configmap/discourse.conf > /discourse/config/discourse.conf
echo "--> DONE"
# Always precompile assets
exec env RAILS_ENV="production" bundle exec rake assets:precompile
\ No newline at end of file
......@@ -6,11 +6,14 @@ envsubst < /tmp/discourse-configmap/discourse.conf > /discourse/config/discourse
envsubst < /tmp/discourse-configmap/sidekiq.yml > /discourse/config/sidekiq.yml
echo "--> DONE"
# Puma is installed, so get memory information
# Get memory information
export_vars=$(python cgroup-limits) ; export $export_vars
export RAILS_ENV="production"
echo "--> Running Unicorn ..."
# Run discourse with Unicorn
exec env LD_PRELOAD=$RUBY_ALLOCATOR thpoff bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
\ No newline at end of file
if bundle exec rake assets:precompile;
then
echo "--> Running Unicorn ..."
# Run discourse with Unicorn
exec env LD_PRELOAD=$RUBY_ALLOCATOR thpoff bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
fi
\ No newline at end of file
#!/bin/bash
echo "--> Running nginx ..."
exec nginx -g "daemon off;"
\ No newline at end of file
# Replace environment variables
echo "--> Overwritting env variables ..."
envsubst < /tmp/discourse-configmap/discourse.conf > /discourse/config/discourse.conf
echo "--> DONE"
# Get memory information
export_vars=$(python cgroup-limits) ; export $export_vars
export RAILS_ENV="production"
# Precompile assets. If succees, proceed with Nginx.
if bundle exec rake assets:precompile;
then
echo "--> Running nginx ..."
exec nginx -g "daemon off;"
fi
......@@ -108,6 +108,54 @@ objects:
name: nginx
command:
- ./run-nginx.sh
env:
- name: NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: HOSTNAME
value: $(NAMESPACE).web.cern.ch
- name: DISCOURSE_CONFIG_DB_HOST
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_HOST_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DB_PORT
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_PORT_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DB_NAME
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_NAME_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DB_USERNAME
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_USERNAME_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DB_PASSWORD
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_PASSWORD_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DEVELOPER_EMAILS
valueFrom:
configMapKeyRef:
key: DISCOURSE_DEVELOPER_EMAILS_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DB_POOL
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_POOL_KEY
name: env-configmap
- name: LANG
valueFrom:
configMapKeyRef:
key: LANG
name: env-configmap
image: gitlab-registry.cern.ch/webservices/discourse-cern:stable
imagePullPolicy: IfNotPresent
ports:
......@@ -115,35 +163,33 @@ objects:
protocol: TCP
resources:
limits:
memory: 400Mi
cpu: 200m
memory: 1Gi
cpu: 1
requests:
memory: 20Mi
cpu: 50m
memory: 320Mi
cpu: 150m
terminationMessagePath: /dev/termination-log
volumeMounts:
- mountPath: /discourse/public/uploads
name: discourse-uploads
- mountPath: /discourse/public/assets
name: discourse-public-assets
- mountPath: /discourse/public/plugins
name: discourse-public-plugins
- mountPath: /discourse/public/backups
name: discourse-backups
- mountPath: /var/cache/nginx
name: var-cache-nginx
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 10
initialDelaySeconds: 180
periodSeconds: 20
successThreshold: 1
tcpSocket:
port: 8080
timeoutSeconds: 10
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 5
initialDelaySeconds: 900
periodSeconds: 20
successThreshold: 1
tcpSocket:
port: 8080
......@@ -171,16 +217,12 @@ objects:
name: discourse-backups
- mountPath: /discourse/public/assets
name: discourse-public-assets
- mountPath: /discourse/public/plugins
name: discourse-public-plugins
- mountPath: /discourse/tmp
name: discourse-tmp
- mountPath: /discourse/logs
name: discourse-logs
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 10
initialDelaySeconds: 180
periodSeconds: 20
successThreshold: 1
tcpSocket:
port: 3000
......@@ -188,7 +230,7 @@ objects:
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 900
periodSeconds: 10
periodSeconds: 20
successThreshold: 1
tcpSocket:
port: 3000
......@@ -286,7 +328,6 @@ objects:
configMapKeyRef:
key: LANG
name: env-configmap
dnsPolicy: ClusterFirst
restartPolicy: Always
securityContext:
......@@ -357,80 +398,9 @@ objects:
volumeMounts:
- mountPath: /discourse/public/uploads
name: discourse-uploads
- name: init-assets
command:
- ./init-assets.sh
env:
- name: NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: HOSTNAME
value: $(NAMESPACE).web.cern.ch
- name: DISCOURSE_CONFIG_DB_HOST
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_HOST_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DB_PORT
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_PORT_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DB_NAME
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_NAME_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DB_USERNAME
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_USERNAME_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DB_PASSWORD
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_PASSWORD_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DEVELOPER_EMAILS
valueFrom:
configMapKeyRef:
key: DISCOURSE_DEVELOPER_EMAILS_KEY
name: env-configmap
- name: DISCOURSE_CONFIG_DB_POOL
valueFrom:
configMapKeyRef:
key: DISCOURSE_DB_POOL_KEY
name: env-configmap
- name: LANG
valueFrom:
configMapKeyRef:
key: LANG
name: env-configmap
image: gitlab-registry.cern.ch/webservices/discourse-cern:stable
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: '1'
memory: 1Gi
requests:
cpu: 200m
memory: 320Mi
volumeMounts:
- mountPath: /discourse/public/assets
name: discourse-public-assets
- mountPath: /discourse/public/plugins
name: discourse-public-plugins
volumes:
- name: discourse-public-assets
emptyDir: {}
- name: discourse-public-plugins
emptyDir: {}
- name: discourse-tmp
emptyDir: {}
- name: discourse-logs
emptyDir: {}
- name: var-cache-nginx
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment