Skip to content
This repository was archived by the owner on Jan 3, 2022. It is now read-only.

Commit 68df1dc

Browse files
authored
Merge pull request #66 from csalmeida/docker
Improves Dockerfile Setup
2 parents 0378f90 + 3dae176 commit 68df1dc

File tree

3 files changed

+57
-9
lines changed

3 files changed

+57
-9
lines changed

.dockerignore

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ node_modules
33
docs
44
screenshots
55
.nvmrc
6+
.git
7+
.github
68
.gitignore
79
.gitattributes
810
.nojekyll
@@ -11,4 +13,30 @@ README.md
1113

1214
# Docker
1315
docker
14-
docker-compose.yml
16+
docker-compose.yml
17+
.dockerignore
18+
19+
# =========================
20+
# Operating System Files
21+
# =========================
22+
23+
# OSX
24+
# =========================
25+
26+
.DS_Store
27+
.AppleDouble
28+
.LSOverride
29+
30+
# Thumbnails
31+
._*
32+
33+
# Files that might appear on external disk
34+
.Spotlight-V100
35+
.Trashes
36+
37+
# Directories potentially created on remote AFP share
38+
.AppleDB
39+
.AppleDesktop
40+
Network Trash Folder
41+
Temporary Items
42+
.apdisk

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ npm run build
137137
1. [Install Docker](https://docs.docker.com/engine/install/). For MacOS and Windows, [Docker Desktop](https://docs.docker.com/engine/install/#desktop) is recommended instead.
138138
1. Run `docker compose up -d`. This will run the development environment.
139139

140+
Rebuild and run Docker container from a clean slate with with:
141+
142+
```bash
143+
# Change directory into the project.
144+
cd protonmail-themes
145+
```
146+
147+
```bash
148+
docker compose rm &&
149+
docker compose pull &&
150+
docker compose build --no-cache &&
151+
docker compose up -d --force-recreate
152+
```
153+
140154
**Additional notes:**
141155

142156
- To examine the container run `docker ps`.

docker/node.dockerfile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
# This image makes use of a Node image running on Linux Alpine
2-
FROM node:15-alpine3.13
1+
# This image makes use of a Node image running on Linux Alpine (latest versions of both)
2+
# Using digest SHA256 increases security
3+
FROM node:lts-alpine@sha256:8d5d490d1e18c9069b34b4a57df1cb3b8cd1b756f2f63f7b8240f39d7c01c402
4+
5+
# Adds a package to act as PID 1 so that Node doesn't take that place.
6+
# Node wasn't built to run as PID 1 and avoiding it prevents unexpected behaviour.
7+
RUN apk add dumb-init
38

49
# A work directory is required to be used by npm install
510
WORKDIR /var/projects/protonmail-themes
611

712
# Copy all project files to the container
813
# Files in the location of this file are copied to WORKDIR in the container
9-
COPY . .
10-
11-
# Makes sure npm is up to date otherwise install dependencies attempts will fail
12-
RUN npm install -g npm
14+
# Scopes permissions to user node instead of root.
15+
COPY --chown=node:node . .
1316

1417
# Install dependencies
15-
RUN npm install
18+
RUN npm ci
19+
20+
# Switches user from root to node.
21+
USER node
1622

1723
# The process this container should run
18-
CMD ["npm", "start"]
24+
CMD ["dumb-init", "npm", "start"]

0 commit comments

Comments
 (0)