Create docker
This commit is contained in:
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
**/node_modules
|
||||||
|
**/build
|
||||||
|
**/Dockerfile
|
||||||
25
Dockerfile
Normal file
25
Dockerfile
Normal 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"]
|
||||||
20
Makefile
20
Makefile
@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user