Skip to content

Commit

Permalink
Optimise docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
timiscoding committed Jul 20, 2020
1 parent 8b63d26 commit b41c335
Show file tree
Hide file tree
Showing 12 changed files with 2,116 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"git.ignoreLimitWarning": true
"git.ignoreLimitWarning": true,
"python.pythonPath": "/Users/tim/.pyenv/versions/3.7.7/bin/python"
}
4 changes: 2 additions & 2 deletions client/.devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"dockerComposeFile": [
"../docker-compose.yml"
],
"service": "patientor-frontend",
"service": "patientor",
// keep container running after vs code closes to prevent accidentally shutting down both
// containers if closing either client or server vscode window
"shutdownAction": "none",
Expand All @@ -12,7 +12,7 @@
"esbenp.prettier-vscode"
],
// Open the sub-folder with the source code
"workspaceFolder": "/patientor-client",
"workspaceFolder": "/patientor",
"postCreateCommand": "npm install",
"forwardPorts": [3000]
}
8 changes: 3 additions & 5 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM ubuntu
FROM node:10-alpine
ARG apiurl
WORKDIR /patientor-client
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash
RUN apt-get install -y nodejs
WORKDIR /patientor
COPY . .
EXPOSE 3000
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
"last 1 safari version"
]
},
"proxy": "http://patientor-backend:3001"
"proxy": "http://patientor-api:3001"
}
14 changes: 7 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
version: '3'

services:
patientor-backend:
patientor-api:
build:
context: ./server
dockerfile: ./server/dev.Dockerfile
image: patientor-backend
dockerfile: ./dev.Dockerfile
image: patientor-api:alpine-dev
ports:
- 3001
environment:
- REDIS_HOST=redis
depends_on:
- redis
container_name: patientor-server
container_name: patientor-api
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
redis:
Expand All @@ -21,12 +21,12 @@ services:
- redis:/data
command: ["redis-server", "--appendonly", "yes"]
container_name: patientor-db
patientor-frontend:
patientor:
build: ./client
image: patientor-frontend
image: patientor
ports:
- 3000
container_name: patientor-client
container_name: patientor
command: sleep infinity

volumes:
Expand Down
4 changes: 2 additions & 2 deletions server/.devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "Patientor Server",
"dockerComposeFile": ["../docker-compose.yml"],
"service": "patientor-backend",
"service": "patientor-api",
"shutdownAction": "none",
"workspaceFolder": "/patientor-server",
"workspaceFolder": "/patientor-api",
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
Expand Down
9 changes: 2 additions & 7 deletions server/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
FROM ubuntu
FROM node:10-alpine

RUN apt-get update && apt-get install -y curl && \
curl -sL https://deb.nodesource.com/setup_12.x | bash && \
apt-get install -y nodejs && \
apt-get purge -y --autoremove curl

WORKDIR /app
WORKDIR /patientor-api
COPY . .

EXPOSE 3001
Loading

0 comments on commit b41c335

Please sign in to comment.