Skip to content

Commit

Permalink
Merge 44519d3 into 210684e
Browse files Browse the repository at this point in the history
  • Loading branch information
patjouk committed Jul 3, 2019
2 parents 210684e + 44519d3 commit 40ba57c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
13 changes: 13 additions & 0 deletions .devcontainer/devcontainer.json
@@ -0,0 +1,13 @@
{
"name": "Mozilla Foundation CMS",
"dockerFile": "../dockerfiles/Dockerfile.python",
"context": "..",
"extensions": [
"ms-python.python"
],
"settings": {
"terminal.integrated.shell.linux": "bash",
"python.pipenvPath": "/usr/local/bin/pipenv",
"python.linting.flake8Path": "flake8"
}
}
6 changes: 1 addition & 5 deletions dockerfiles/Dockerfile.node
@@ -1,14 +1,10 @@
FROM node:8-alpine
FROM node:8-stretch-slim

WORKDIR /app/

# Copy package files in the container
COPY package.json package-lock.json ./

RUN apk add --no-cache \
zlib-dev \
build-base

RUN npm install

# Install visual testing tools separately with CI true to suppress the hundreds lines of "unziping".
Expand Down
10 changes: 1 addition & 9 deletions dockerfiles/Dockerfile.python
@@ -1,4 +1,4 @@
FROM python:3.7-alpine
FROM python:3.7-slim

# We want output
ENV PYTHONUNBUFFERED 1
Expand All @@ -7,14 +7,6 @@ ENV PYTHONDONTWRITEBYTECODE 1

WORKDIR /app/

# Install dependencies for pillow and psycopg
RUN apk add --no-cache \
build-base \
jpeg-dev \
zlib-dev \
postgresql-dev \
postgresql-client

# Install pipenv
RUN pip install pipenv

Expand Down
29 changes: 27 additions & 2 deletions docs/local_development_with_docker.md
Expand Up @@ -2,6 +2,7 @@

This documentation is composed of three main sections:
- [How to install and use Docker for local development](./local_development_with_docker.md#how-to-use)
- [Connecting Docker to your code editor](./local_development_with_docker.md#connecting-docker-to-your-code-editor)
- [Docker 101 and how we use it with the foundation site](./local_development_with_docker.md#docker-vocabulary-and-overview). Start here if you're new to Docker
- [FAQ](./local_development_with_docker.md#faq)

Expand Down Expand Up @@ -86,6 +87,30 @@ Use `invoke docker-npm update`.
You don't need to rebuild the `watch-static-files` image.


---

## Connecting Docker to your code editor


### Pycharm

This feature is only available for the professional version of Pycharm. Follow the official instructions [available here](https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html#config-docker)

### Visual Studio Code

Visual Studio Code use a feature called Dev Container to run Docker projects. The configuration files are in the `.devconatainer` directory. This feature is only available starting VSCode 1.35 stable. For now, we're only creating a python container to get Intellisense, we're not running the full project inside VSCode. We may revisit this in the future if Docker support in VSCode improves.

A few things to keep in mind when using that setup:
- Do not use the terminal in VSCode when running `invoke docker-` commands: use a local terminal instead,
- when running `inv docker-catchup` or installing python dependencies, you will need to rebuild the Dev Container. To do that, press `F1` and look for `Rebuild Container`.

#### Instructions:

- Install the [Remote - containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers),
- Open the project in VSCode: it detects the Dev Container files and a popup appears: click on `Reopen in a Container`,
- Wait for the Dev Container to build,
- Work as usual and use the docker invoke commands in a terminal outside VSCode.

---

## Docker vocabulary and overview
Expand All @@ -111,8 +136,8 @@ I would recommend watching [An Intro to Docker for Djangonauts](https://www.yout
All our containers run on Linux.

For local development, we have two Dockerfiles that define our images:
- `Dockerfile.node`: use a node8-alpine base image from the Docker Hub and install node dependencies,
- `Dockerfile.python`: use a python3.6-alpine base image, install required build dependencies before installing pipenv and the project dependencies.
- `Dockerfile.node`: use a node8 Debian Stretch slim base image from the Docker Hub and install node dependencies,
- `Dockerfile.python`: use a python3.7 Debian Stretch slim base image, install required build dependencies before installing pipenv and the project dependencies.
We don't have a custom image for running postgres and use one from the Docker Hub.

The `docker-compose.yml` file describes the 3 services that the project needs to run:
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Expand Up @@ -51,7 +51,7 @@ def manage(ctx, command, option=None, flag=None):
@task
def runserver(ctx):
"""Start a web server"""
manage(ctx, "runserver")
manage(ctx, "runserver 0.0.0.0:8000")


@task
Expand Down

0 comments on commit 40ba57c

Please sign in to comment.