Files
blog-ahmza-com/Dockerfile
T

33 lines
921 B
Docker
Raw Normal View History

2024-07-16 20:49:28 +01:00
FROM golang:1.22.5-alpine AS build
2024-06-21 23:35:24 +01:00
ARG GITLAB_TOKEN
2022-05-30 18:38:51 +01:00
2024-08-03 20:20:42 +00:00
ARG TARGETARCH
2022-05-30 18:38:51 +01:00
# install curl and git
2024-07-16 20:49:28 +01:00
RUN apk add --update curl git
2022-05-30 18:38:51 +01:00
2024-07-16 20:49:28 +01:00
# download and unnzip the hugo binary
2024-08-03 20:20:42 +00:00
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
2022-05-30 18:38:51 +01:00
2024-07-16 20:49:28 +01:00
# clone the blog repository
2024-07-16 19:51:01 +01:00
RUN git clone https://oauth2:$GITLAB_TOKEN@gitlab.com/AHMZA/blog.git
2022-05-30 18:38:51 +01:00
2024-07-16 20:49:28 +01:00
# set blog (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
2024-07-16 20:49:28 +01:00
COPY --from=build /go/blog/nginx.conf /etc/nginx/nginx.conf
2022-05-30 18:38:51 +01:00
# copy the static files
2024-07-16 20:49:28 +01:00
COPY --from=build /go/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