Skip to content
Permalink
Browse files

Replace Alpine by Debian stretch slim for Docker local dev (#3253)

* Replace Alpine by Debian stretch slim

* DevContainer configuration for VSCode (#3295)

* Replace Alpine by Debian stretch slim

* devcontainer!

* custom dockerfile for devcontainer

* update runserver

* install ssh

* switch the approach to using a container just for intellisense instead of trying to run services inside vscode

* docs

* Update docs/local_development_with_docker.md

Co-Authored-By: Alan Mooiman <amooiman@gmail.com>

* doc update
  • Loading branch information...
patjouk committed Jul 3, 2019
1 parent 210684e commit 6b7be5bbf2aed782765c65e087310d0aebbdb551
@@ -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"
}
}
@@ -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".
@@ -1,4 +1,4 @@
FROM python:3.7-alpine
FROM python:3.7-slim

# We want output
ENV PYTHONUNBUFFERED 1
@@ -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

@@ -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)

@@ -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
@@ -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:
@@ -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

0 comments on commit 6b7be5b

Please sign in to comment.
You can’t perform that action at this time.