build changes
Some checks failed
Publish Image / publish (push) Waiting to run
Test / build (push) Waiting to run
Build / build (push) Has been cancelled

This commit is contained in:
Chuck Smith
2024-03-28 15:11:47 -04:00
parent fd8311b280
commit 138df71cc8
22 changed files with 392 additions and 99 deletions

77
Dockerfile Normal file
View File

@@ -0,0 +1,77 @@
# Build
FROM golang:alpine AS build
RUN apk add --no-cache -U make
RUN mkdir -p /src
WORKDIR /src
# Copy Makefile
COPY Makefile ./
# Copy go.mod and go.sum and install and cache dependencies
COPY go.mod .
COPY go.sum .
# Copy static assets
COPY ./internal/server/static/ace/* ./internal/server/static/ace/
COPY ./internal/server/static/* ./internal/server/static/
# Copy sources
COPY *.go ./
COPY ./internal/ast/*.go ./internal/ast/
COPY ./internal/builtins/*.go ./internal/builtins/
COPY ./internal/code/*.go ./internal/code/
COPY ./internal/compiler/*.go ./internal/compiler/
COPY ./internal/context/*.go ./internal/context/
COPY ./internal/eval/*.go ./internal/eval/
COPY ./internal/lexer/*.go ./internal/lexer/
COPY ./internal/object/*.go ./internal/object/
COPY ./internal/parser/*.go ./internal/parser/
COPY ./internal/server/*.go ./internal/server/
COPY ./internal/token/*.go ./internal/token/
COPY ./internal/typing/*.go ./internal/typing/
COPY ./internal/utils/*.go ./internal/utils/
COPY ./internal/vm/*.go ./internal/vm/
COPY ./cmd/monkey/*.go ./cmd/monkey/
COPY ./cmd/monkey-server/*.go ./cmd/monkey-server/
# Version (there there is no .git in Docker build context)
# NOTE: This is fairly low down in the Dockerfile instructions so
# we don't break the Docker build cache just by changing
# unrelated files that actually haven't changed but caused the
# VERSION value to change.
ARG VERSION="0.0.0"
# Build cli and server binaries
RUN make build VERSION=$VERSION
# Runtime
FROM alpine:latest
RUN apk --no-cache -U add su-exec shadow ca-certificates tzdata
ENV PUID=1000
ENV PGID=1000
RUN addgroup -g "${PGID}" monkey && \
adduser -D -H -G monkey -h /var/empty -u "${PUID}" monkey && \
mkdir -p /data && chown -R monkey:monkey /data
VOLUME /data
WORKDIR /
# force cgo resolver
ENV GODEBUG=netdns=cgo
COPY --from=build /src/monkey /usr/local/bin/monkey
COPY --from=build /src/monkey-server /usr/local/bin/monkey-server
COPY .dockerfiles/entrypoint.sh /init
ENTRYPOINT ["/init"]
CMD ["monkey"]