Files
blog-ahmza-com/Dockerfile.old
T

33 lines
921 B
Docker
Raw Normal View History

2024-11-16 20:03:11 +00:00
FROM golang:1.22.5-alpine AS build
ARG GITLAB_TOKEN
ARG TARGETARCH
# install curl and git
RUN apk add --update curl git
# download and unnzip the hugo binary
RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.128.2/hugo_0.128.2_linux-${TARGETARCH}.tar.gz > hugo.tar.gz && tar -zxf hugo.tar.gz && mv hugo /usr/local/bin
# clone the blog repository
RUN git clone https://oauth2:$GITLAB_TOKEN@gitlab.com/AHMZA/blog.git
# set blog (folder we just cloned) as the current DIR
WORKDIR blog
# run hugo --minify to generate static files
RUN hugo --minify --gc
# Nginx image is as basic as we can get without introducing further complexity
FROM nginx
# copy the nginx.conf file
COPY --from=build /go/blog/nginx.conf /etc/nginx/nginx.conf
# copy the static files
COPY --from=build /go/blog/public/ /usr/share/nginx/html
# Tell the image to expose port 80 for HTTP, SSL provided by reverse proxy.
EXPOSE 80