Skip to content

Commit 116d8d4

Browse files
committed
Refactoring to build to a busybox container
1 parent a0bb44a commit 116d8d4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Multi-stage
22
# 1) Node image for building frontend assets
3-
# 2) nginx stage to serve frontend assets
3+
# 2) busybox stage to serve frontend assets
44
# based on https://typeofnan.dev/how-to-serve-a-react-app-with-nginx-in-docker/
5+
# and https://lipanski.com/posts/smallest-docker-image-static-website
56

67
FROM node:18 AS builder
78
WORKDIR /app
@@ -19,13 +20,16 @@ COPY . .
1920
RUN npm run build
2021

2122

22-
# nginx state for serving content
23-
FROM nginx:alpine
23+
FROM busybox
2424

25-
WORKDIR /usr/share/nginx/html
25+
# Create a non-root user to own the files and run our server
26+
RUN adduser -D static
27+
USER static
28+
WORKDIR /home/static
2629

27-
# Copy static assets from builder stage
30+
# Copy the static website
31+
# Use the .dockerignore file to control what ends up inside the image!
2832
COPY --from=builder /app/build .
2933

30-
# Containers run nginx with global directives and daemon off
31-
#ENTRYPOINT ["nginx", "-g", "daemon off;"]
34+
# Run BusyBox httpd
35+
CMD ["busybox", "httpd", "-f", "-v", "-p", "3000"]

compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ services:
22
ccn-coverage-vis:
33
build:
44
context: .
5+
stop_grace_period: 1s
56
ports:
6-
- "8080:80"
7+
- "8080:3000"

0 commit comments

Comments
 (0)