fixing github action

This commit is contained in:
Hamza Ahmed
2024-11-16 20:03:11 +00:00
parent fde6e5a9cd
commit 7ddb01ce95
3 changed files with 82 additions and 31 deletions
Regular → Executable
+10 -31
View File
@@ -1,32 +1,11 @@
FROM golang:1.22.5-alpine AS build
ARG GITLAB_TOKEN
FROM ghcr.io/hugomods/hugo:0.128.2 AS build
ARG GH_ACCESS_TOKEN
WORKDIR /tmp/hugo
COPY . .
RUN apk add --no-cache make && git config --global url.https://${GH_ACCESS_TOKEN}@github.com/.insteadOf https://github.com/ && make build
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
FROM nginx:alpine-slim
WORKDIR /usr/share/nginx/html
COPY docker/nginx.conf /etc/nginx/nginx.conf
COPY --from=build /tmp/hugo/public .
EXPOSE 80/tcp