|
| 1 | +FROM golang:alpine |
| 2 | + |
| 3 | +# Set necessary environmet variables needed for our image |
| 4 | +ENV GO111MODULE=on \ |
| 5 | + CGO_ENABLED=0 \ |
| 6 | + GOOS=linux \ |
| 7 | + GOARCH=amd64 |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH |
| 12 | +ENV PGDATA /var/lib/postgresql/data |
| 13 | +ENV POSTGRES_DB headscale |
| 14 | +ENV POSTGRES_USER admin |
| 15 | + |
| 16 | +ENV LANG en_US.utf8 |
| 17 | + |
| 18 | +RUN apk update && \ |
| 19 | + apk add git su-exec tzdata libpq postgresql-client postgresql postgresql-contrib gnupg supervisor inotify-tools wireguard-tools openssh && \ |
| 20 | + mkdir /docker-entrypoint-initdb.d && \ |
| 21 | + rm -rf /var/cache/apk/* |
| 22 | + |
| 23 | +RUN gpg --keyserver ipv4.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 |
| 24 | +RUN gpg --list-keys --fingerprint --with-colons | sed -E -n -e 's/^fpr:::::::::([0-9A-F]+):$/\1:6:/p' | gpg --import-ownertrust |
| 25 | +RUN wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.7/gosu-amd64" && \ |
| 26 | + wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.7/gosu-amd64.asc" && \ |
| 27 | + gpg --verify /usr/local/bin/gosu.asc && \ |
| 28 | + rm /usr/local/bin/gosu.asc && \ |
| 29 | + chmod +x /usr/local/bin/gosu |
| 30 | +RUN apk --purge del gnupg ca-certificates |
| 31 | + |
| 32 | +VOLUME /var/lib/postgresql/data |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | +RUN rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key |
| 38 | + |
| 39 | +WORKDIR /build |
| 40 | + |
| 41 | +RUN git clone https://github.com/juanfont/headscale.git |
| 42 | + |
| 43 | +WORKDIR /build/headscale |
| 44 | + |
| 45 | +RUN go build cmd/headscale/headscale.go |
| 46 | + |
| 47 | +COPY headscale.sh /headscale.sh |
| 48 | +COPY postgres.sh /postgres.sh |
| 49 | +COPY supervisord.conf /etc/supervisord.conf |
| 50 | + |
| 51 | +WORKDIR / |
| 52 | + |
| 53 | +RUN mkdir -p /run/postgresql |
| 54 | +RUN chown postgres:postgres /run/postgresql |
| 55 | + |
| 56 | +RUN adduser -S headscale |
| 57 | + |
| 58 | +#ENV GIN_MODE release |
| 59 | + |
| 60 | +EXPOSE 8000 |
| 61 | + |
| 62 | +CMD ["supervisord","--nodaemon", "--configuration", "/etc/supervisord.conf"] |
0 commit comments