惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

楚天乐的全栈之路

procrastinated单词终极指南:发音/中文解释/英文解释/词源/例句全解 | myxtea学英语 - 楚天乐的全栈之路 Vocabulary: Prolific - 楚天乐的全栈之路 DCT离散余弦变换和JPEG 压缩算法 - 楚天乐的全栈之路 c语言float和bytes array转换 - 楚天乐的全栈之路 地图找出口算法python实现 - 楚天乐的全栈之路 使用Vault管理服务器各种密码 - 楚天乐的全栈之路 windows环境pip无法安装dlib库的终极解决 - 楚天乐的全栈之路 Windows WLS2使用本机ss代理访问github - 楚天乐的全栈之路 php中__METHOD__和_FUNCTION__的区别 - 楚天乐的全栈之路
写个dockerfile自动部署hugo - 楚天乐的全栈之路
2022-03-05 · via 楚天乐的全栈之路

创建dockerfile

FROM golang:1.17-alpine

# Optionally set HUGO_BUILD_TAGS to "extended" or "nodeploy" when building like so:
#   docker build --build-arg HUGO_BUILD_TAGS=extended .
ARG HUGO_BUILD_TAGS

ARG CGO=1
ENV CGO_ENABLED=${CGO}
ENV GOOS=linux
ENV GO111MODULE=on

ENV HUGO_VERSION=0.93.3
ENV HUGO_USER=hugo
ENV BASE_DIRECORY=/home/hugo
ENV SITE_NAME=hugosite
ENV HUGO_SITE_DIRECORY=${BASE_DIRECORY}/${SITE_NAME}
ENV HUGO_URL=https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz
#hugo_extended_0.93.3_Linux-64bit.tar.gz

ENV GLIBC_VER=2.34-r0
ENV GLIBC_NAME=glibc-${GLIBC_VER}.apk

ENV THEME_NAME=book
ENV THEME_URL=https://github.com/alex-shpak/hugo-book

RUN set -ex && \
    apk --update add libstdc++ curl ca-certificates git

# glibc
ENV GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc
ENV GLIBC_VERSION=2.30-r0
RUN set -ex && \
    apk --update add libstdc++ curl ca-certificates && \
    for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION}; \
        do curl -sSL ${GLIBC_REPO}/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done && \
    apk add --allow-untrusted /tmp/*.apk && \
    rm -v /tmp/*.apk && \
    /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib

# 下载安装
ADD ${HUGO_URL} /tmp/

RUN tar -xzf /tmp/*.tar.gz -C /tmp && \
    file="$(echo HUGO_URL)" && echo $file && \
    file="$(ls -ll /tmp/hugo)" && echo $file && \
    mv /tmp/hugo /usr/bin/ && \
    #rm -rf /tmp/* && \
    file="$(ls -ll /usr/bin/hugo)" && echo $file && \
    adduser ${HUGO_USER} -D

#CMD sh
WORKDIR ${BASE_DIRECORY}
#VOLUME ["$BASE_DIRECORY", "$BASE_DIRECORY"]
#CMD ["ls","-a"]

# 安装
RUN hugo new site ${SITE_NAME}  # && file="$(ls -ll /home/hugo/hugosite)" && echo $file  && echo $file && file="$(pwd)" && echo $file

WORKDIR ${HUGO_SITE_DIRECORY}

RUN git init \
    && git submodule add ${THEME_URL} themes/${THEME_NAME}  \
    && cp -R themes/${THEME_NAME}/exampleSite/content . \
    && echo -e "baseURL = 'http://example.org/' \r\nlanguageCode = 'en-us' \r\ntitle = 'My New Hugo Site' \r\ntheme = '${THEME_NAME}'" > config.toml

EXPOSE 20000

CMD ["hugo", "server", "-D", "--bind", "0.0.0.0", "--port", "20000"]
#CMD sh

构建运行镜像

docker build -f ./Dockerfile.hugo -t myhugo .
docker run -i -t -p 20000:20000 myhugo

配置物理机上nginx转发到docker容器

vim nginx/conf/vhost/域名.conf
server {
    listen       80;
    #listen       [::]:80 default_server;
    server_name  域名;

    location / {
        access_log 访问日志文件;
        error_log 错误日志文件;

        proxy_pass http://127.0.0.1:20000/;

        proxy_redirect off;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    }
}