Skip to content

Commit

Permalink
Production ready dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeseblubber committed Nov 16, 2020
1 parent f12b612 commit 8531db8
Show file tree
Hide file tree
Showing 26 changed files with 1,699 additions and 752 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -52,6 +52,12 @@ We :heart: contributions big or small. See [CONTRIBUTING.md](https://github.com

Come say hi to us on [Slack](https://join.slack.com/t/papercups-io/shared_invite/zt-h0c3fxmd-hZi1Zp8~D61S6GD16aMqmg)! :wave:

## Docker Development

Kubernetes

## Docker Production Deployment

## License

MIT © Papercups
1,778 changes: 1,099 additions & 679 deletions assets/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/package.json
Expand Up @@ -4,7 +4,7 @@
"private": true,
"license": "MIT",
"dependencies": {
"@papercups-io/chat-widget": "^1.1.2",
"@papercups-io/chat-widget": "^1.1.3",
"@papercups-io/storytime": "^1.0.6",
"@sentry/react": "^5.20.1",
"@stripe/react-stripe-js": "^1.1.2",
Expand Down Expand Up @@ -37,7 +37,7 @@
"react-helmet": "^6.1.0",
"react-markdown": "^4.3.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.1",
"react-scripts": "3.4.1",
"react-syntax-highlighter": "^12.2.1",
"recharts": "^1.8.5",
"remark-breaks": "^2.0.0",
Expand Down
18 changes: 1 addition & 17 deletions config/prod.exs
Expand Up @@ -20,22 +20,6 @@ config :chat_api, ChatApiWeb.Endpoint,
# Do not print debug messages in production
config :logger, level: :info

# ## SSL Support
#
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
# config :chat_api, ChatApiWeb.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [
# port: 443,
# cipher_suite: :strong,
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH"),
# transport_options: [socket_opts: [:inet6]]
# ]
#
# The `cipher_suite` is set to `:strong` to support only the
# latest and more secure SSL ciphers. This means old browsers
# and clients may not be supported. You can set it to
Expand All @@ -56,4 +40,4 @@ config :logger, level: :info

# Finally import the config/prod.secret.exs which loads secrets
# and configuration from environment variables.
import_config "prod.secret.exs"
# import_config "prod.secret.exs"
41 changes: 0 additions & 41 deletions config/prod.secret.exs

This file was deleted.

78 changes: 78 additions & 0 deletions config/releases.exs
@@ -0,0 +1,78 @@
import Config

database_url =
System.get_env("DATABASE_URL") ||
raise """
environment variable DATABASE_URL is missing.
For example: ecto://USER:PASS@HOST/DATABASE
"""

secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
raise """
environment variable SECRET_KEY_BASE is missing.
You can generate one by calling: mix phx.gen.secret
"""

backend_url =
System.get_env("BACKEND_URL") ||
raise """
environment variable BACKEND_URL is missing.
For example: myselfhostedwebsite.com or papercups.io
"""

# Configure your database
config :chat_api, ChatApi.Repo,
url: database_url,
show_sensitive_data_on_connection_error: false,
pool_size: 10

ssl_key_path = System.get_env("SSL_KEY_PATH")
ssl_cert_path = System.get_env("SSL_CERT_PATH")
https = (ssl_cert_path && ssl_key_path) != nil

if https do
config :chat_api, ChatApiWeb.Endpoint,
http: [
port: String.to_integer(System.get_env("PORT") || "4000"),
transport_options: [socket_opts: [:inet6]]
],
url: [host: backend_url],
pubsub_server: ChatApi.PubSub,
secret_key_base: secret_key_base,
https: [
port: 443,
cipher_suite: :strong,
otp_app: :hello,
keyfile: ssl_key_path,
certfile: ssl_cert_path
],
server: true
else
config :chat_api, ChatApiWeb.Endpoint,
http: [
port: String.to_integer(System.get_env("PORT") || "4000"),
transport_options: [socket_opts: [:inet6]]
],
url: [host: backend_url],
pubsub_server: ChatApi.PubSub,
secret_key_base: secret_key_base,
server: true
end

# https = (ssl_cert_path && ssl_key_path) != nil
# # ## SSL Support
# #
# # To get SSL working, you will need to add the `https` key
# # to the previous section and set your `:url` port to 443:
# if ssl_key_path && ssl_cert_path do
# config :chat_api, ChatApiWeb.Endpoint,
# url: [host: "example.com", port: 443],
# https: [
# port: 443,
# cipher_suite: :strong,
# keyfile: ssl_key_path,
# certfile: ssl_cert_path,
# transport_options: [socket_opts: [:inet6]]
# ]
# end
212 changes: 212 additions & 0 deletions deployment-old.yaml
@@ -0,0 +1,212 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2"
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"app":"papercups"},"name":"papercups","namespace":"default"},"spec":{"replicas":1,"revisionHistoryLimit":10,"selector":{"matchLabels":{"app":"papercups"}},"template":{"metadata":{"labels":{"app":"papercups"}},"spec":{"containers":[{"command":["/usr/src/app/docker-entrypoint.sh"],"env":[{"name":"DOMAIN","value":"domain.com"},{"name":"DATABASE_URL","value":"ecto://postgres:postgres@db/postgres"},{"name":"BACKEND_URL","value":"https://chat.domain.com"},{"name":"PAPERCUPS_SLACK_CLIENT_ID","value":"xxxxxxxx"},{"name":"PAPERCUPS_SLACK_CLIENT_SECRET","value":"xxxxxxxx"}],"image":"papercups/papercups:latest","imagePullPolicy":"Always","name":"papercups","ports":[{"containerPort":3000},{"containerPort":4000}],"resources":{"limits":{"cpu":"200m","memory":"256Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}}],"terminationGracePeriodSeconds":120}}}}
creationTimestamp: "2020-10-22T20:05:24Z"
generation: 2
labels:
app: papercups
managedFields:
- apiVersion: apps/v1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.: {}
f:kubectl.kubernetes.io/last-applied-configuration: {}
f:labels:
.: {}
f:app: {}
f:spec:
f:progressDeadlineSeconds: {}
f:replicas: {}
f:revisionHistoryLimit: {}
f:selector:
f:matchLabels:
.: {}
f:app: {}
f:strategy:
f:rollingUpdate:
.: {}
f:maxSurge: {}
f:maxUnavailable: {}
f:type: {}
f:template:
f:metadata:
f:labels:
.: {}
f:app: {}
f:spec:
f:containers:
k:{"name":"papercups"}:
.: {}
f:command: {}
f:env:
.: {}
k:{"name":"BACKEND_URL"}:
.: {}
f:name: {}
f:value: {}
k:{"name":"DATABASE_URL"}:
.: {}
f:name: {}
f:value: {}
k:{"name":"DOMAIN"}:
.: {}
f:name: {}
f:value: {}
k:{"name":"PAPERCUPS_SLACK_CLIENT_ID"}:
.: {}
f:name: {}
f:value: {}
k:{"name":"PAPERCUPS_SLACK_CLIENT_SECRET"}:
.: {}
f:name: {}
f:value: {}
f:image: {}
f:imagePullPolicy: {}
f:name: {}
f:ports:
.: {}
k:{"containerPort":3000,"protocol":"TCP"}:
.: {}
f:containerPort: {}
f:protocol: {}
k:{"containerPort":4000,"protocol":"TCP"}:
.: {}
f:containerPort: {}
f:protocol: {}
f:resources:
.: {}
f:limits:
.: {}
f:cpu: {}
f:memory: {}
f:requests:
.: {}
f:cpu: {}
f:memory: {}
f:terminationMessagePath: {}
f:terminationMessagePolicy: {}
f:dnsPolicy: {}
f:restartPolicy: {}
f:schedulerName: {}
f:securityContext: {}
f:terminationGracePeriodSeconds: {}
manager: kubectl-client-side-apply
operation: Update
time: "2020-10-22T21:59:08Z"
- apiVersion: apps/v1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
f:deployment.kubernetes.io/revision: {}
f:status:
f:availableReplicas: {}
f:conditions:
.: {}
k:{"type":"Available"}:
.: {}
f:lastTransitionTime: {}
f:lastUpdateTime: {}
f:message: {}
f:reason: {}
f:status: {}
f:type: {}
k:{"type":"Progressing"}:
.: {}
f:lastTransitionTime: {}
f:lastUpdateTime: {}
f:message: {}
f:reason: {}
f:status: {}
f:type: {}
f:observedGeneration: {}
f:readyReplicas: {}
f:replicas: {}
f:updatedReplicas: {}
manager: kube-controller-manager
operation: Update
time: "2020-11-06T18:16:22Z"
name: papercups
namespace: default
resourceVersion: "160333"
selfLink: /apis/apps/v1/namespaces/default/deployments/papercups
uid: ec819ae8-5dda-4609-b53c-45d9218f58ee
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: papercups
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: papercups
spec:
containers:
- command:
- /usr/src/app/docker-entrypoint.sh
env:
- name: DOMAIN
value: domain.com
- name: DATABASE_URL
value: ecto://postgres:postgres@db/postgres
- name: BACKEND_URL
value: https://chat.domain.com
- name: PAPERCUPS_SLACK_CLIENT_ID
value: xxxxxxxx
- name: PAPERCUPS_SLACK_CLIENT_SECRET
value: xxxxxxxx
image: papercups/papercups:latest
imagePullPolicy: Always
name: papercups
ports:
- containerPort: 3000
protocol: TCP
- containerPort: 4000
protocol: TCP
resources:
limits:
cpu: 200m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 120
status:
availableReplicas: 1
conditions:
- lastTransitionTime: "2020-10-22T20:05:24Z"
lastUpdateTime: "2020-10-22T21:59:10Z"
message: ReplicaSet "papercups-b45769b7b" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
- lastTransitionTime: "2020-11-06T18:16:22Z"
lastUpdateTime: "2020-11-06T18:16:22Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
observedGeneration: 2
readyReplicas: 1
replicas: 1
updatedReplicas: 1

0 comments on commit 8531db8

Please sign in to comment.