Dockerfile, Makefile: build into nginx container

This commit is contained in:
RyanSquared 2023-07-22 21:50:14 -05:00
parent c66428703c
commit f645dd5cc0
Signed by untrusted user who does not match committer: ryan
GPG Key ID: 8E401478A3FBEF72
3 changed files with 19 additions and 17 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
Dockerfile
Makefile
_site

View File

@ -9,14 +9,9 @@ COPY Gemfile.lock /home
COPY _vendor /home/_vendor
WORKDIR /home
RUN bundle install
COPY . /home
RUN jekyll build
FROM ruby:3.2.2-alpine
RUN apk update && apk add git
COPY --from=builder /usr/local/bundle /usr/local/bundle
RUN mkdir -p /home
WORKDIR /home
CMD ["jekyll", "serve", "--host", "0.0.0.0"]
FROM nginx
COPY --from=builder /home/_site /usr/share/nginx/html

View File

@ -3,15 +3,19 @@ build:
# Build Docker image
docker build -t distrust-co .
# Export site to _site directory
docker run -v $(shell pwd):/home -it distrust-co jekyll build
.PHONY: fullclean
fullclean: clean
docker rmi distrust-co
.PHONY: clean
clean:
rm -r _site
_site: build
mkdir -p _site
docker run distrust-co tar c -C /usr/share/nginx/html . | tar x -C _site
.PHONY: serve
serve:
# Run Docker container with listener for current dir and port mapping
docker run -v $(shell pwd):/home -p 0.0.0.0:4000:4000 -it distrust-co
.PHONY: clean
clean:
# Remove _site directory
rm -rf _site
docker run --rm -p 0.0.0.0:4000:80 -it distrust-co