Files
blog-ahmza-com/Dockerfile
T

36 lines
1.2 KiB
Docker
Raw Normal View History

2022-05-30 18:38:51 +01:00
# use the classic alpine image
2024-07-16 19:51:01 +01:00
#FROM alpine as Builder
FROM golang:1.22.5-alpine as Builder
2024-06-21 23:35:24 +01:00
ARG GITLAB_TOKEN
2022-05-30 18:38:51 +01:00
# install curl and git
2024-07-16 19:51:01 +01:00
# RUN apk add --update curl git
RUN apk add git
2022-05-30 18:38:51 +01:00
# download and unnzip the hugo binary then place it in /usr/local/bin
2024-07-16 19:51:01 +01:00
#RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.121.1/hugo_0.121.1_linux-arm64.tar.gz > hugo.tar.gz && tar -zxf hugo.tar.gz && mv hugo /usr/local/bin
RUN CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@v0.128.2
2022-05-30 18:38:51 +01:00
# clone the blog repository as well as the theme submodule
2024-07-16 19:51:01 +01:00
# RUN git clone --recurse-submodules https://oauth2:$GITLAB_TOKEN@gitlab.com/AHMZA/blog.git
RUN git clone https://oauth2:$GITLAB_TOKEN@gitlab.com/AHMZA/blog.git
2022-05-30 18:38:51 +01:00
# set blog (the folder we just cloned) as the current DIR
2022-02-23 22:09:56 +00:00
WORKDIR blog
2022-05-30 18:38:51 +01:00
# run hugo --minify to generate static files
2023-12-28 08:08:55 +00:00
RUN hugo --minify --gc
2022-05-30 18:38:51 +01:00
# Nginx image is as basic as we can get without introducing further complexity
2021-12-09 00:03:53 +00:00
FROM nginx
2022-05-30 18:38:51 +01:00
# copy the nginx.conf file
2022-02-23 22:09:56 +00:00
COPY --from=Builder /blog/nginx.conf /etc/nginx/nginx.conf
2022-05-30 18:38:51 +01:00
# copy the static files
2022-02-23 22:09:56 +00:00
COPY --from=Builder /blog/public/ /usr/share/nginx/html
2022-05-30 18:38:51 +01:00
2023-06-21 15:31:02 +01:00
# Tell the image to expose port 80 for HTTP, SSL provided by reverse proxy.
EXPOSE 80