Skip to content

Commit

Permalink
Adding support for --user for Alpine based images and some minor clea…
Browse files Browse the repository at this point in the history
…ning. #5
  • Loading branch information
klakegg committed Nov 17, 2018
1 parent ebe204a commit dccb783
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 65 deletions.
18 changes: 13 additions & 5 deletions dist/alpine/Dockerfile-alpine
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
FROM klakegg/hugo:base AS base

FROM klakegg/hugo:base-certs as certs


FROM klakegg/hugo:base-certs as certs

FROM scratch as image

COPY files /files
COPY --from=base /bin/hugo /files/bin/hugo
COPY --from=certs /etc/ssl/certs /files/etc/ssl/certs


FROM alpine:3.7

FROM alpine:3.8

ENV HUGO_BIND="0.0.0.0" \
HUGO_DESTINATION="/target" \
HUGO_ENV="DEV"

COPY --from=base /bin/hugo /bin/hugo
COPY files /
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
COPY --from=image /files /

RUN apk --no-cache add busybox-suid bash bash-completion \
&& mkdir /etc/bash_completion.d \
&& hugo gen autocomplete > /dev/null

EXPOSE 1313

Expand Down
22 changes: 15 additions & 7 deletions dist/alpine/Dockerfile-ext-alpine
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
FROM klakegg/hugo:base AS base

FROM klakegg/hugo:base-certs as certs

FROM ubuntu:18.04 AS ubuntu

FROM klakegg/hugo:base-certs as certs


FROM scratch as image

FROM frolvlad/alpine-glibc:alpine-3.7
COPY files /files
COPY --from=base /bin/hugo-extended /files/bin/hugo
COPY --from=certs /etc/ssl/certs /files/etc/ssl/certs
COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25 /files/usr/lib/libstdc++.so.6


FROM frolvlad/alpine-glibc:alpine-3.8

ENV HUGO_BIND="0.0.0.0" \
HUGO_DESTINATION="/target" \
HUGO_ENV="DEV"

COPY --from=base /bin/hugo-extended /bin/hugo
COPY files /
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
RUN apk add --no-cache libstdc++ busybox-suid bash bash-completion

COPY --from=image /files /

RUN apk add --no-cache libstdc++
COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25 /usr/lib/libstdc++.so.6
RUN mkdir /etc/bash_completion.d \
&& hugo gen autocomplete > /dev/null

EXPOSE 1313

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,3 @@ alias h="hugo"
if [ "$HUGO_PANDOC" != "" ]; then
alias pandoc="$HUGO_PANDOC"
fi


if [ -e /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
fi
28 changes: 28 additions & 0 deletions dist/alpine/files/etc/shadow
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
root:$6$5sgrRV/p.pxx/ac/$XbuTxCOspW1Emdesk5HsML6CI8SiYjtJdDODAM26pixFEpw7T6yO3AAe0nOmWGJNpIvZ9Z6Ip4fHqz7YzSTue/:17852:0:::::
bin:!::0:::::
daemon:!::0:::::
adm:!::0:::::
lp:!::0:::::
sync:!::0:::::
shutdown:!::0:::::
halt:!::0:::::
mail:!::0:::::
news:!::0:::::
uucp:!::0:::::
operator:!::0:::::
man:!::0:::::
postmaster:!::0:::::
cron:!::0:::::
ftp:!::0:::::
sshd:!::0:::::
at:!::0:::::
squid:!::0:::::
xfs:!::0:::::
games:!::0:::::
postgres:!::0:::::
cyrus:!::0:::::
vpopmail:!::0:::::
ntp:!::0:::::
smmsp:!::0:::::
guest:!::0:::::
nobody:!::0:::::
8 changes: 8 additions & 0 deletions dist/alpine/files/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/sh

if [ "$(id -u)" != "0" ]; then
su - root <<! > /dev/null
alpine
chown $(id -u).$(id -g) /src /target
adduser -D -h /src -u $(id -u) hugo
!
fi

case "$1" in

# Commands from hugo
Expand Down
13 changes: 1 addition & 12 deletions dist/alpine/files/shell.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
#!/bin/sh

# Install bash
apk --no-cache add bash bash-completion

# Setting up autocomplete for hugo
mkdir /etc/bash_completion.d
hugo gen autocomplete > /dev/null

# Notify user
echo "Shell ready."
echo

# Start bash
bash
bash -l
14 changes: 7 additions & 7 deletions dist/busybox/Dockerfile-busybox
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
FROM klakegg/hugo:base AS base

FROM klakegg/hugo:base-certs as certs


FROM scratch AS files

COPY --from=base /bin/hugo /bin/hugo
COPY files /
FROM scratch as image

COPY files /files
COPY --from=base /bin/hugo /files/bin/hugo
COPY --from=certs /etc/ssl/certs /files/etc/ssl/certs

FROM klakegg/hugo:base-certs as certs


FROM busybox:1.28
FROM busybox:1.29

ENV HUGO_BIND="0.0.0.0" \
HUGO_DESTINATION="/target" \
HUGO_ENV="DEV"

COPY --from=files / /
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
COPY --from=image /files /

EXPOSE 1313

Expand Down
12 changes: 9 additions & 3 deletions dist/debian/Dockerfile-debian
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ FROM klakegg/hugo:base AS base



FROM debian:9.4-slim
FROM scratch as image

COPY files /files
COPY --from=base /bin/hugo /files/bin/hugo



FROM debian:9.6-slim

ENV HUGO_BIND="0.0.0.0" \
HUGO_DESTINATION="/target" \
HUGO_ENV="DEV"

COPY --from=base /bin/hugo /bin/hugo
COPY files /
COPY --from=image /files /

RUN apt update \
&& apt install -y bash-completion \
Expand Down
10 changes: 8 additions & 2 deletions dist/debian/Dockerfile-ext-debian
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ FROM klakegg/hugo:base AS base



FROM scratch as image

COPY files /files
COPY --from=base /bin/hugo-extended /files/bin/hugo



FROM debian:9.4-slim

ENV HUGO_BIND="0.0.0.0" \
HUGO_DESTINATION="/target" \
HUGO_ENV="DEV"

COPY --from=base /bin/hugo-extended /bin/hugo
COPY files /
COPY --from=image /files /

RUN apt update \
&& apt install -y curl gnupg bash-completion \
Expand Down
7 changes: 7 additions & 0 deletions dist/debian/files/etc/profile.d/hugo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

PS1="\e[1;32mhugo\e[m:\e[1;34m\w\e[m\$ "
HOME=/src

alias hugo="sh /run.sh"
alias h="hugo"
11 changes: 0 additions & 11 deletions dist/debian/files/root/.bashrc

This file was deleted.

2 changes: 1 addition & 1 deletion dist/debian/files/shell.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

# Start bash
bash
bash -l
7 changes: 7 additions & 0 deletions dist/ubuntu/files/etc/profile.d/hugo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

PS1="\e[1;32mhugo\e[m:\e[1;34m\w\e[m\$ "
HOME=/src

alias hugo="sh /run.sh"
alias h="hugo"
11 changes: 0 additions & 11 deletions dist/ubuntu/files/root/.bashrc

This file was deleted.

2 changes: 1 addition & 1 deletion dist/ubuntu/files/shell.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

# Start bash
bash
bash -l

0 comments on commit dccb783

Please sign in to comment.