GithubHelp home page GithubHelp logo

sanic-org / sanic-docker Goto Github PK

View Code? Open in Web Editor NEW
18.0 6.0 7.0 8 KB

Official Docker images for Sanic

Home Page: https://cloud.docker.com/u/sanicframework/repository/docker/sanicframework/sanic

License: MIT License

Dockerfile 43.63% Makefile 56.37%
docker sanic python3 alpine-linux web-framework

sanic-docker's Introduction

Sanic Dockerfile

This repository is for the Sanic Docker image.

What does this image do?

It preinstalls the latest Sanic LTS version on top of a Python 3.7. The container runs Alpine Linux.

How do I use this?

Setup your own Dockerfile

FROM sanicframework/sanic:LTS

RUN mkdir /srv
COPY . /srv

EXPOSE 8888

ENTRYPOINT ["python3", "/srv/my-sanic-server.py"]

Build it

docker build -t my-sanic-server .

Run it as you would any other container

docker run my-sanic-server

Are you looking for a best practices solution with some guidance on how to setup your Sanic App? We will be releasing a second image in the future with some more guidance.

sanic-docker's People

Contributors

ahopkins avatar oliverzgy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sanic-docker's Issues

Update do Sanic 19.12

Hello,

I believe 19.12 is also a LTS version. Could you update the image ?

Thanks,
Damien

Include the WORKDIR option in Dockerfile and mkdir /srv error

Proposed changes:

FROM sanicframework/sanic:LTS

RUN mkdir -p /srv  # <-- by adding -p, it will do nothing if the folder already exists
COPY . /srv
WORKDIR /srv  # <-- new

EXPOSE 8888

ENTRYPOINT ["python3", "my-sanic-server.py"]  # <-- removed /srv/ 

Rationale

If WORKDIR is not set, all paths referred to in my-sanic-server.py will start from root / instead of /srv. This breaks relative paths in "my-sanic-server.py" when accessing other files in the container or e.g. creating logs.

User story

I modified the Docker file found under base to include SQLAlchemy and copied the equivalent of "my-sanic-server.py" to /srv/ + a SQLite3 database (sample.db). My Python file uses a relative path to access sample.db. I didn't have any problems when running locally, but in a Docker container I was getting errors as: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: foo.
Originally I thought it was a permission problem ("users" inside a Docker container inheriting the same permissions of the host OS's user with the same UID), but I finally found out that the issue was with the path. It was solved by setting WORKDIR.


mkdir

Also, RUN mkdir /srv in your README to create Docker images based on FROM sanicframework/sanic:LTS does not work, as it gives the error:

mkdir: cannot create directory ‘/srv’: File exists

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.