62 lines
1.2 KiB
Docker
62 lines
1.2 KiB
Docker
|
# syntax=docker/dockerfile:1.4
|
||
|
FROM golang:1.20-alpine AS build
|
||
|
|
||
|
WORKDIR /app
|
||
|
|
||
|
RUN <<EOF
|
||
|
apk --update add --no-cache git bash make alpine-sdk g++
|
||
|
git clone https://git.iratusmachina.com/iratusmachina/gocustomurls.git gurls
|
||
|
cd gurls
|
||
|
make build
|
||
|
EOF
|
||
|
|
||
|
FROM alpine AS run
|
||
|
|
||
|
ARG USERNAME
|
||
|
ARG UID
|
||
|
ARG GID
|
||
|
ARG PORT
|
||
|
|
||
|
RUN <<EOF
|
||
|
addgroup --gid ${GID} ${USERNAME}
|
||
|
adduser --uid ${UID} --ingroup ${USERNAME} --gecos "" --disabled-password --home "/home/$USERNAME" $USERNAME
|
||
|
chmod -R 755 /home/$USERNAME
|
||
|
chown -R ${UID}:${GID} /home/$USERNAME
|
||
|
EOF
|
||
|
|
||
|
COPY --from=build /app/gurls/artifacts/gocustomurls /home/$USERNAME/gocustomurls
|
||
|
|
||
|
RUN <<EOF
|
||
|
mkdir -p /var/lib/apptemp
|
||
|
cp /home/$USERNAME/gocustomurls /var/lib/apptemp/gocustomurls
|
||
|
chown -R ${UID}:${GID} /home/$USERNAME
|
||
|
chown -R ${UID}:${GID} /var/lib/apptemp
|
||
|
ls -lah /home/$USERNAME
|
||
|
EOF
|
||
|
|
||
|
|
||
|
ENV HOME=/home/$USERNAME
|
||
|
|
||
|
COPY <<EOF start.sh
|
||
|
#!/usr/bin/env sh
|
||
|
printenv
|
||
|
cd "${HOME}"
|
||
|
ls -lah .
|
||
|
if [ ! -f "${HOME}/gocustomurls" ]
|
||
|
then
|
||
|
cp /var/lib/apptemp/gocustomurls ${HOME}/gocustomurls
|
||
|
rm /var/lib/apptemp/gocustomurls
|
||
|
fi
|
||
|
${HOME}/gocustomurls -conf ${HOME}/config.json
|
||
|
EOF
|
||
|
|
||
|
RUN <<EOF
|
||
|
chown ${UID}:${GID} start.sh
|
||
|
chmod u+x start.sh
|
||
|
EOF
|
||
|
|
||
|
EXPOSE $PORT
|
||
|
|
||
|
USER $USERNAME
|
||
|
|
||
|
CMD ["sh", "-c", "./start.sh" ]
|