Learning About Best Practices for Docker and Node

Today I've tried to update one of my Docker apps that uses React, Enzyme, and Jest. This lead me on a wild goose chase about react-test-renderer and best practices for Docker builds for Node.js. I'm still not sure where the problem is (Enzyme, maybe?). But I found three useful resources for Docker and Node.js: Docker and Node.js Best Practices Node + Docker Hello World, for Showing Good Defaults for Using Node.
Read more →

Wrangling With Docker

I'm currently wrangling with Docker. I'm working through some Docker courses on Udemy and Sitepoint. Plus, I'm reading articles on how to improve my Docker files. I like playing with tools like Docker and docker-compose. But they add a lot of complexity to an application. Here are some useful links and resources about Docker: Advanced multi-stage build patterns by Tõnis Tiigi 9 Common Dockerfile Mistakes by Jorge Silva Production-ready Docker packaging Docker for Node.
Read more →

Create a Multi-Stage Docker Build for Python Flask and Postgres

A few days ago, I created a Docker build for Flask with PostgreSQL (both with Alpine Linux and with Debian Linux). Installing psypcopg-2 binary (required for Postgres) requires you to build the package from source. Now the Docker image grows in size, as it still contains the build artifacts. The solution? Multi-stage Docker builds. Let's say we have the following docker-compose.yml file. There are two services: a Flask API called users and a Postgres database called users-db.
Read more →

Install psycopg2-binary With Docker

How to build a Python app with PostgreSQL I'm currently setting up a Flask app with PostgreSQL and Docker. Like most examples you'll find on the internet, the course I'm following uses Alpine Linux as a base image. Alpine's selling point is the small image size. But Alpine uses a different C library, musl, instead of glibc. That's one of the reasons why the website Pythonspeed recommends Debian Buster as the base image for Python (as of 2019).
Read more →

Docker NGinx 405 POST Not Allowed

Today it took me over one hour to debug an error with Docker and Nginx. Every time I tried to submit a form with a POST method, NGinx gave me a 405 error: “405 Not Allowed”. I originally thought that Nginx overrode React Router settings and tried to troubleshoot my production NGinx config. StackOverflow had some ideas: POST request not allowed - 405 Not Allowed - nginx, even with headers included.
Read more →

Remove Docker Containers And More

Read more →

Permission Denied When Installing NPM Packages With Docker

I have the following Dockerfile for a React app:

base image FROM node:11.12.0-alpine # set working directory WORKDIR /usr/src/app # add /usr/src/app/node_modules/.bin to $PATH ENV PATH /usr/src/app/node_modules/.bin:$PATH # install and cache app dependencies COPY package.json /usr/src/app/package.json COPY package-lock.json /usr/src/app/package-lock.json RUN npm install react-scripts@3.0.1 -g –silent RUN chown -R node:node . USER node RUN npm ci # start app CMD ["npm", "start"] After setting up the work directory I copy the package.

Read more →

Friday Picks 013

Read more →

Run Docker-compose as Root User: Python Coverage Permission Denied

I'm learning test-driven development with the course Microservices with Docker, Flask, and React. It's been a lot of fun. I've also learned more about using Docker and docker-compose. The course uses Coverage.py for measuring Python code coverage. However, Coverage.py and Docker don't play well with each other if you run the Docker container as a normal (non-root) user. PermissionError: [Errno 13] Permission denied: 'usr/src/app/.coverage' Here is the Dockerfile:

base image FROM python:3.

Read more →

Deploying Docker with Travis to Heroku Woes

Read more →