Build static and use nginx instead of the full hugo server (#8)
This pull request will close #4 Hugo server needs about 800mb of memory just to do what nginx can with a way smaller requirements, so it makes sense to stop using `hugo` for serving statics
This commit is contained in:
		
							
								
								
									
										34
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								.drone.yml
									
									
									
									
									
								
							@@ -1,13 +1,19 @@
 | 
			
		||||
---
 | 
			
		||||
# ----------------------------------------------
 | 
			
		||||
# -- Build the site and push it to the registry
 | 
			
		||||
# ----------------------------------------------
 | 
			
		||||
kind: pipeline
 | 
			
		||||
type: kubernetes
 | 
			
		||||
name: Build badhouseplants.net
 | 
			
		||||
 | 
			
		||||
trigger:
 | 
			
		||||
  branch:
 | 
			
		||||
    - main
 | 
			
		||||
  event:
 | 
			
		||||
  - push
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: Publish the Helm chart
 | 
			
		||||
  when:
 | 
			
		||||
    branch:
 | 
			
		||||
      - main
 | 
			
		||||
  image: alpine/helm
 | 
			
		||||
  environment:
 | 
			
		||||
    GITEA_TOKEN:
 | 
			
		||||
@@ -18,19 +24,13 @@ steps:
 | 
			
		||||
    - helm repo add  --username allanger --password $GITEA_TOKEN allanger-charts https://git.badhouseplants.net/api/packages/allanger/helm
 | 
			
		||||
    - helm cm-push "./chart-package/$(ls chart-package)" allanger-charts
 | 
			
		||||
 | 
			
		||||
- name: Init git submodules
 | 
			
		||||
- name: Init git submodules with themes
 | 
			
		||||
  image: alpine/git
 | 
			
		||||
  when:
 | 
			
		||||
    branch:
 | 
			
		||||
      - main
 | 
			
		||||
  commands:
 | 
			
		||||
  - git submodule update --init --recursive
 | 
			
		||||
 | 
			
		||||
- name: Get static content
 | 
			
		||||
  image: rclone/rclone:latest
 | 
			
		||||
  when:
 | 
			
		||||
    branch:
 | 
			
		||||
      - main
 | 
			
		||||
  environment:
 | 
			
		||||
    RCLONE_CONFIG_CONTENT:
 | 
			
		||||
      from_secret: RCLONE_CONFIG_CONTENT
 | 
			
		||||
@@ -40,9 +40,6 @@ steps:
 | 
			
		||||
    - rclone copy -P badhouseplants-public:/badhouseplants-static static
 | 
			
		||||
 | 
			
		||||
- name: Build and push the docker image 
 | 
			
		||||
  when:
 | 
			
		||||
    branch:
 | 
			
		||||
      - main
 | 
			
		||||
  image: plugins/docker
 | 
			
		||||
  settings: 
 | 
			
		||||
    registry: git.badhouseplants.net
 | 
			
		||||
@@ -52,16 +49,23 @@ steps:
 | 
			
		||||
    repo: git.badhouseplants.net/allanger/badhouseplants-net
 | 
			
		||||
    tags: latest
 | 
			
		||||
  depends_on:
 | 
			
		||||
    - Init git submodules
 | 
			
		||||
    - Init git submodules with themes
 | 
			
		||||
    - Get static content
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
# ----------------------------------------------
 | 
			
		||||
# -- Upload a newer version of my CV
 | 
			
		||||
# ----------------------------------------------
 | 
			
		||||
kind: pipeline
 | 
			
		||||
type: kubernetes
 | 
			
		||||
name: CV Builder
 | 
			
		||||
when: 
 | 
			
		||||
 | 
			
		||||
trigger:
 | 
			
		||||
  branch:
 | 
			
		||||
    - main
 | 
			
		||||
  event:
 | 
			
		||||
  - push
 | 
			
		||||
  
 | 
			
		||||
steps:
 | 
			
		||||
  - name: Build the CV
 | 
			
		||||
    image: ghcr.io/puppeteer/puppeteer
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,3 +1,4 @@
 | 
			
		||||
node_modules
 | 
			
		||||
static
 | 
			
		||||
content/cv/index.pdf
 | 
			
		||||
public
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -1,13 +1,16 @@
 | 
			
		||||
FROM alpine:latest AS builder
 | 
			
		||||
WORKDIR /src
 | 
			
		||||
COPY . /src
 | 
			
		||||
ARG GOHUGO_LINK=https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_linux-amd64.tar.gz
 | 
			
		||||
RUN apk update && apk add curl tar
 | 
			
		||||
RUN curl -LJO ${GOHUGO_LINK} && tar -xf hugo_0.110.0_linux-amd64.tar.gz
 | 
			
		||||
RUN chmod +x /src/hugo
 | 
			
		||||
RUN mv /src/hugo /usr/local/bin/hugo
 | 
			
		||||
RUN chmod +x /usr/local/bin/hugo
 | 
			
		||||
RUN hugo
 | 
			
		||||
 | 
			
		||||
FROM nginx:stable-alpine
 | 
			
		||||
COPY --from=builder /src/public /var/www
 | 
			
		||||
COPY configs/nginx.conf /etc/nginx/conf.d/default.conf
 | 
			
		||||
EXPOSE 80
 | 
			
		||||
CMD [ "nginx", "-g", "daemon off;" ]
 | 
			
		||||
 | 
			
		||||
FROM alpine:latest
 | 
			
		||||
WORKDIR /src
 | 
			
		||||
COPY --from=builder /src/hugo /usr/bin/hugo
 | 
			
		||||
COPY . /src
 | 
			
		||||
ENTRYPOINT ["/usr/bin/hugo"]
 | 
			
		||||
CMD ["--help"]
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										13
									
								
								configs/nginx.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								configs/nginx.conf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
server {
 | 
			
		||||
       listen 80;
 | 
			
		||||
       listen [::]:80;
 | 
			
		||||
 | 
			
		||||
       server_name badhouseplants.com www.badhouseplants.com;
 | 
			
		||||
 | 
			
		||||
       root /var/www;
 | 
			
		||||
       index index.html; # Hugo generates HTML
 | 
			
		||||
 | 
			
		||||
       location / {
 | 
			
		||||
               try_files $uri $uri/ =404;
 | 
			
		||||
       }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user