erigon-pulse/Dockerfile
Cory 74cf9840ae
Patch plumbing of docker-compose UID/GID build args (#4527)
* Patch plumbing of docker-compose UID/GID build args

* Fallback to 1000/1000 if DOCKER_(U|G)ID not set

* Revise README.md instructions for docker further

* Fix existing typo forc 'servie' -> 'service'

* Rename PUID/GUID -> UID/GID

* Specify user in erigon docker service

* Rely on .env instead of specifying :-1000

* Polish Makefile for docker use case

* one more helpful comment

* make docker should use UID/GID --build-arg

* Fix make docker and more fail-fast if envvar set incorrect

* mv .env->.env.example to not intefere existing workflows

* Specify envvars in docker CI

* Adjust validate_docker_build_args to permit non-erigon user

* Also run docker CI target on macos-11 os

* Add DOCKER_UID, DOCKER_GID in hooks/build

* Patch docker build arg validation for macos

* Add actions-setup-docker@master for macos

* Don't run automated test for docker macos

* Cleanup Makefile

* Comments, targets for erigon users

* More Makefile cleanup, debugging still

* Typo fix

* Create subdirs before calling ls

* Get rid of flaky validation

* DOCKER_UID, DOCKER_GID init to runner if not set

* Get rid of unnecessary variable for now

* Improved README based on new changes

* Proper uid/gid `make user_*` when no envars set

* Fix typo in Makefile comment

* Fix make docker as sudo user
2022-06-30 16:11:37 +06:00

55 lines
1.6 KiB
Docker

# syntax = docker/dockerfile:1.2
FROM docker.io/library/golang:1.18-alpine3.15 AS builder
RUN apk --no-cache add build-base linux-headers git bash ca-certificates libstdc++
WORKDIR /app
ADD . .
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/tmp/go-build \
--mount=type=cache,target=/go/pkg/mod \
make all db-tools
FROM docker.io/library/alpine:3.15
RUN apk add --no-cache ca-certificates libstdc++ tzdata
# copy compiled artifacts from builder
COPY --from=builder /app/build/bin/* /usr/local/bin/
# Setup user and group
#
# from the perspective of the container, uid=1000, gid=1000 is a sensible choice
# (mimicking Ubuntu Server), but if caller creates a .env (example in repo root),
# these defaults will get overridden when make calls docker-compose
ARG UID=1000
ARG GID=1000
RUN adduser -D -u $UID -g $GID erigon
USER erigon
RUN mkdir -p ~/.local/share/erigon
EXPOSE 8545 \
8551 \
8546 \
30303 \
30303/udp \
42069 \
42069/udp \
8080 \
9090 \
6060
# https://github.com/opencontainers/image-spec/blob/main/annotations.md
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.description="Erigon Ethereum Client" \
org.label-schema.name="Erigon" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://torquem.ch" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/ledgerwatch/erigon.git" \
org.label-schema.vendor="Torquem" \
org.label-schema.version=$VERSION