Skip to content

Commit 59f8412

Browse files
committed
update docker build to work with dinghy certs
This adds support to the docker build for dev to use self-signed certificates shared with dinghy. With this change can now configure rollcall and canvas to work with dingy configured for ssl. Change-Id: I8b0805e9ac844ef52d7dccca9ea1285d57136a88 Reviewed-on: https://gerrit.instructure.com/c/rollcall-attendance/+/227604 Tested-by: Service Cloud Jenkins <[email protected]> Reviewed-by: Simon Williams <[email protected]> Reviewed-by: Adrian Packel <[email protected]> QA-Review: Keith Garner <[email protected]> Product-Review: Keith Garner <[email protected]>
1 parent 99ec5f0 commit 59f8412

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg m
2424

2525
COPY config/nginx/location.conf /usr/src/nginx/location.d/location.conf
2626

27+
RUN if [ "$DEV_BUILD" = 'true' ]; then echo 'docker ALL=(ALL) NOPASSWD: SETENV: /usr/sbin/update-ca-certificates' >> /etc/sudoers; fi
28+
2729
USER docker
2830

2931
COPY --chown=docker:docker Gemfile Gemfile.lock $APP_HOME
@@ -43,4 +45,4 @@ RUN RAILS_ENV=production \
4345
SECRET_KEY_BASE=fake \
4446
bundle exec rake assets:precompile
4547

46-
CMD ["/tini", "--", "bin/startup"]
48+
ENTRYPOINT [ "/usr/src/app/docker-entrypoint.sh" ]

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@ outgoing address parameter to an email address on your own domain; otherwise,
4848
your reports will be sent from "`Roll Call <[email protected]>`",
4949
which is most certainly not what you want.
5050

51-
### 3. Docker build + Database migrations:
51+
### 3. Configure your docker environment for SSL
52+
53+
Do to recent changes in browsers, the session cookies for rollcall are required to have `SaveSite=None` and `secure`.
54+
Due to `secure` local development is easier if you configure your dockerized canvas and rollcall to use SSL. If you are
55+
using dinghy for OS X based development. You can find instructions on how to create self signed certificates at
56+
https://github.com/codekitchen/dinghy-http-proxy/blob/master/README.md#ssl-support
57+
58+
The default docker-compose.override.yml file will share your ~/.dinghy/cert directory into the docker containers and add
59+
the certifications in that directory as trusted certificates to the container.
60+
61+
### 4. Docker build + Database migrations:
5262

5363
NOTE: By default this setup uses postgres. To use mysql instead, export:
5464

@@ -65,7 +75,7 @@ rake tasks, you just have to run them in the container:
6575
docker-compose run --rm web bundle exec rake db:create
6676
docker-compose run --rm web bundle exec rake db:migrate
6777

68-
### 4. Run it!
78+
### 5. Run it!
6979

7080
You should be able to start everything with:
7181

@@ -78,7 +88,7 @@ can visit your app in the browser by going to:
7888

7989
`http://rollcall.docker`
8090

81-
### 5. Add Roll Call to Canvas:
91+
### 6. Add Roll Call to Canvas:
8292

8393
In Canvas, go to Account >> Settings >> Apps, click "Add App", and use the following settings:
8494

docker-compose.override.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,28 @@ services:
66
args:
77
DEV_BUILD: 'true'
88
env_file: .env
9+
environment:
10+
DEV_BUILD: 'true'
911
external_links:
1012
- ${PROXY_CONTAINER:-dinghy_http_proxy}:canvas.docker
1113
volumes:
1214
- .:/usr/src/app
1315
- tmp:/usr/src/app/tmp
16+
- ~/.dinghy/certs:/usr/local/share/ca-certificates:ro
1417

1518
work:
1619
build:
1720
args:
1821
DEV_BUILD: 'true'
1922
env_file: .env
23+
environment:
24+
DEV_BUILD: 'true'
2025
external_links:
2126
- ${PROXY_CONTAINER:-dinghy_http_proxy}:canvas.docker
2227
volumes:
2328
- .:/usr/src/app
2429
- tmp:/usr/src/app/tmp
30+
- ~/.dinghy/certs:/usr/local/share/ca-certificates:ro
2531

2632
volumes:
2733
tmp:

docker-entrypoint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
4+
if [ "$DEV_BUILD" = "true" ]; then
5+
sudo /usr/sbin/update-ca-certificates
6+
fi
7+
8+
COMMAND=$@
9+
10+
if [ "x$COMMAND" = "x" ]; then
11+
exec /tini -- bin/startup
12+
fi
13+
14+
exec "$@"

0 commit comments

Comments
 (0)