Skip to content
This repository was archived by the owner on Jul 12, 2019. It is now read-only.

Added guide for Deploying Lucky app with Docker #99

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Added guide for Deploying Lucky app with Docker #99

wants to merge 2 commits into from

Conversation

nicbet
Copy link
Contributor

@nicbet nicbet commented Jan 24, 2018

A guide that describes how to build a docker container image of your Lucky app for deployment. Background: https://gitter.im/luckyframework/Lobby?at=5a67a423e0141226508243c0

Copy link
Contributor

@hanneskaeufler hanneskaeufler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I like the intro, I think this will benefit the guides!


### `LUCKY_ENV`

Lucky needs a couple of environment variables to operate as a production app. The first is the `LUCKY_ENV`. We'll set it to `production`. This will signal to Lucky that it should, for example, display absolute timestamps in the server log, and use additional environment variables for its configuration:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will signal to Lucky that it should, for example, display absolute timestamps in the server log, <= I think that bit about the absolute timestamps is uninteresting to most users. Can we rather say something like This will signal to Lucky that it should, for example, use the production database?

* Compile all assets

```bash
$ brunch build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be yarn prod now


## FAQ

### Help! I can't stop the running application with `CTRL+C`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulcsmith
Copy link
Member

Thanks for writing this @nicbet and thanks for taking a look @hanneskaeufler. I don't have much experience with Docker so I appreciate your input.

FROM crystallang/crystal:latest

COPY ./ /opt/crystal
RUN crystal build --no-debug -o /opt/crystal/server /opt/crystal/src/server.cr
Copy link
Contributor

@hanneskaeufler hanneskaeufler May 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could advise to use --release here as well?

@hanneskaeufler
Copy link
Contributor

@nicbet do you think it is reasonable to assume that someone using this guide has already set up his app locally? I am asking because the Dockerfile does not do crystal deps or yarn install. Not saying that is wrong, but I am wondering what the docker-ers (? 🤓) out there are doing. Myself e.g. I am building and running the app in docker (sometimes). Thats why the dockerfile looks more like

FROM hanneskaeufler/crystal-node-ruby

# add application code
ADD . /app
WORKDIR /app

# install app dependencies (crystal)
RUN crystal deps

# install app dependencies (node)
RUN yarn install

# precompile assets (via brunch)
RUN ./bin/compile_assets build --production

RUN crystal build src/server.cr
CMD ./server

I DO think it is a good idea not to go into docker-compose (for database e.g) straight away. Maybe in a tiny section in the end?

@nicbet
Copy link
Contributor Author

nicbet commented May 26, 2018

@hanneskaeufler you make a good point. I think the focus of the guide as on deployment via Docker, rather than using a Crystal Docker container as a development environment (which I am doing with pretty much every language myself these days). To develop using a Docker image, you'd have to create a new base image (like you have done with hanneskauefler/crystal-node-ruby) and add all required dependencies (such as node) into the image.

I'm okay with adding an additional section, or perhaps a separate guide.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants