Create docker

This commit is contained in:
Eden Kirin
2024-01-28 21:49:03 +01:00
parent 5a43ce875f
commit 8a97b3daf6
3 changed files with 48 additions and 0 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
**/node_modules
**/build
**/Dockerfile

25
Dockerfile Normal file
View File

@ -0,0 +1,25 @@
# stage 1: build node frontend
FROM node:21 as node-builder
WORKDIR /node-builder
COPY ./public ./public
COPY ./src ./src
COPY ./package.json .
COPY ./package-lock.json .
COPY ./tsconfig.json .
RUN \
npm install && \
npm run build
FROM busybox:1.36-musl
RUN adduser -D pingator
USER pingator
WORKDIR /www
COPY --from=node-builder /node-builder/build /www
# Run BusyBox httpd
CMD ["busybox", "httpd", "-f", "-v", "-h", "/www", "-p", "3000"]

View File

@ -1,3 +1,7 @@
CONTAINER_NAME=pingator
IMAGE_NAME=pingator
EXTERNAL_PORT=8080
run: run:
@npm start @npm start
@ -6,3 +10,19 @@ build:
- @rm -rf build - @rm -rf build
@npm run build @npm run build
@rm build/static/js/*.map @rm build/static/js/*.map
docker-build:
- @docker image rm $(IMAGE_NAME)
@docker \
build \
--progress plain \
--tag $(IMAGE_NAME) \
.
docker-run:
@docker \
run \
--publish $(EXTERNAL_PORT):3000 \
--name=$(CONTAINER_NAME) \
--detach \
$(IMAGE_NAME)