diff --git a/.dockerignore b/.dockerignore index f1ba3fde..02bbf616 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,12 +1,17 @@ +# Directories +.git/ +.github/ +.idea/ node_modules/ -test + +# Files +.editorconfig +.eslintignore +.gitignore +.travis.yml *.log +docker-compose* Dockerfile* -README.md LICENSE -style.tailwindcss - -.idea/ -.github/ -.travis.yml -.eslintignore +README.md +style.tailwindcss \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 24a2b673..96f1d006 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,30 @@ -# Stage 1: build the application -FROM nginx:alpine AS build +# Stage 1: Build site +FROM node:alpine AS build + +WORKDIR /app + +COPY package.json . + +# Install dependencies +RUN npm install + +COPY . . + +# Build site +RUN npm run build + +# Stage 2: Create final image +FROM nginx:alpine + RUN rm -rf /etc/nginx/conf.d/* + COPY nginx.conf /etc/nginx/ -COPY public /usr/share/nginx/html/ -EXPOSE 80 -# Stage 2: final image -FROM alpine:latest -RUN apk add --no-cache nginx && mkdir -p /run/nginx -COPY --from=build /usr/share/nginx/html/ /usr/share/nginx/html/ -COPY --from=build /etc/nginx/nginx.conf /etc/nginx/nginx.conf +# Copy site data to nginx web root +COPY --from=build /app/public/ /usr/share/nginx/html/ + EXPOSE 80 + +HEALTHCHECK CMD curl --fail http://localhost || exit 1 + CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 00000000..fab5b722 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,10 @@ +--- +version: '3' + +services: + cheatsheets: + build: . + image: cheatsheets + restart: unless-stopped + ports: + - 8080:80 \ No newline at end of file