Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified Dockerfile to build site; added Docker Compose config #461

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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
34 changes: 25 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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;"]
10 changes: 10 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
version: '3'

services:
cheatsheets:
build: .
image: cheatsheets
restart: unless-stopped
ports:
- 8080:80