GithubHelp home page GithubHelp logo

shanesveller / docker-phoenix-framework Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 9.0 9 KB

Docker image ready for Phoenix Framework apps (Elixir-Lang)

Home Page: https://registry.hub.docker.com/u/shanesveller/phoenix-framework/

License: MIT License

docker-phoenix-framework's Introduction

Image Contents

This image is based on the official Elixir image and includes the features of that image.

At the time of writing, this Dockerfile results in an image that also contains:

  • NodeJS 4.x (installed via NodeSource's APT repository)
  • npm 3.8.9

It also includes the following ONBUILD steps for convenience of use as a base image itself:

  • Creates a working directory for your app at /usr/src/app
  • Adds files like package.json and brunch-config.js and installs npm dependencies
  • Sets MIX_ENV to prod
  • Copies files needed to determine Mix config and dependencies, then downloads and compiles those dependencies

All of the above occur before any custom instructions in a child Dockerfile that uses FROM to inherit from this one.

Image Versions

The latest tag on Docker Hub should always be reasonably in sync with the tip of master within this repository via automated builds. Starting with 1.2.4, git tags will also result in a corresponding Docker Hub tag.

Checking Versions

Want to check the current versions included in the latest image in light of future rebuilds?

  • docker run -it --rm shanesveller/phoenix-framework node -v
  • docker run -it --rm shanesveller/phoenix-framework npm -v
  • docker run -it --rm shanesveller/phoenix-framework mix hex.info

Caveats

  • MIX_ENV is set to prod globally for all commands run in the Docker container, unless overridden on a per-command basis or a later ENV Dockerfile instruction
  • When building your own apps based on a third party's Docker image, you should make note of any ONBUILD instructions in the base image's Dockerfile, as these are executed dynamically while building your app, prior to ANY of the instructions in your own Dockerfile.

Alternative images

Not happy with the Dockerfile steps? Having compatibility problems? Try one of these alternatives:

docker-phoenix-framework's People

Contributors

shanesveller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

docker-phoenix-framework's Issues

Error when running docker build

I'm getting an error when trying to build my image based on this one. I have a very simple Phoenix app and followed your blog post minus the docker-compose stuff. I don't need the DB.

Here is the output from my run:

❯ docker build -t my-phoenix-app . 
Sending build context to Docker daemon 526.3 kB
Step 1 : FROM shanesveller/phoenix-framework:latest
# Executing 7 build triggers...
Step 1 : WORKDIR /usr/src/app
 ---> Using cache
Step 1 : COPY *.js* /usr/src/app/
stat Dockerfile: no such file or directory

This is probably my issue but I can't figure it out.

guardian compatibility

Guardian require config.exs or prod.exs on compilation step.
In current Dockerfile we have:

ONBUILD COPY mix.* /usr/src/app/
ONBUILD RUN mix do deps.get --only prod
# phoenix and phoenix_html JS dependencies are included from Hex packages
ONBUILD COPY package.json /usr/src/app/
ONBUILD RUN npm install
ONBUILD RUN mix deps.compile --only prod

ONBUILD COPY . /usr/src/app/
ONBUILD RUN mix compile

As you can see config/* does not exists before we run mix deps.compile. So we get error:

== Compilation error on file lib/guardian.ex ==
** (RuntimeError) Guardian is not configured
    lib/guardian.ex:26: (module)
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6

could not compile dependency :guardian, "mix compile" failed. You can recompile this dependency with "mix deps.compile guardian", update it with "mix deps.update guardian" or clean it with "mix deps.clean guardian"
The command '/bin/sh -c mix deps.compile --only prod' returned a non-zero code: 1

I suggest to change this Dockerfile's lines to:

 ONBUILD COPY . /usr/src/app/
 ONBUILD RUN mix do deps.get --only prod
 ONBUILD RUN npm install
 ONBUILD RUN mix deps.compile --only prod
 ONBUILD RUN mix compile

After this updates build works successfully.

"node" is not available

After I started the server, and after compilation, I got this error:

[info] Running App.Endpoint with Cowboy using http on port 4000
[error] Could not start watcher because "node" is not available. Your Phoenix application is still running, however assets won't be compiled. You may fix this by installing "node" and then running "npm install".

Doesn't the Dockerfile install node already?

License

Hi Shane. Are you able to add a license to your repo? Or if you are feeling lazy let me know what it should be and I'll pop a PR. Thanks.

New hex version

My local hex version is 0.12.
So when I try to build my docker image it fails on last step(compile).

Step 1 : RUN mix compile
 ---> Running in 538f3403fe80
A new Hex version is available (0.12.0), please update with `mix local.hex`
Unchecked dependencies for environment prod:
* tzdata (Hex package)
  lock mismatch: the dependency is out of date (run "mix deps.get" to fetch locked version)
* calendar (Hex package)
  lock mismatch: the dependency is out of date (run "mix deps.get" to fetch locked version)
* calecto (Hex package)
  lock mismatch: the dependency is out of date (run "mix deps.get" to fetch locked version)
* phoenix_calendar (Hex package)
  lock mismatch: the dependency is out of date (run "mix deps.get" to fetch locked version)
** (Mix) Can't continue due to errors on dependencies
The command '/bin/sh -c mix compile' returned a non-zero code: 1

I didn't find issues and forks abilities on docker hub so I've pushed my own version to maslenkov/phoenix-framework; but I don't like reinvent the wheel, so can you upgrade your image? Or create new version?

Phoenix isn't installed

If you run docker run --rm shanesveller/phoenix-framework mix --help you'll notice that phoenix.new is not in the list. It also happens to not be available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.