Skip to content

Commit

Permalink
🚞
Browse files Browse the repository at this point in the history
  • Loading branch information
w13b3 committed Apr 5, 2024
1 parent e963c46 commit fec315b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Dockerfile.redbean-alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# syntax=docker/dockerfile:1
# # FROM args
ARG ALPINE_TAG=3.19.1
ARG IMAGE_TAG=latest

# # build image
FROM redbean-build:${IMAGE_TAG} AS build

# # final image
FROM docker.io/library/alpine:${ALPINE_TAG} AS final

# # set which command RUN should use
SHELL [ "/bin/sh", "-c" ]

# # environment variables
ENV LANG=C.UTF-8

# # final args
ARG USER=redbean
ARG USER_ID=10000
ARG GROUP=cosmopolitanock
ARG GROUP_ID=10001
ARG BIN_DIR=/usr/local/bin

# # copy the $BIN_DIR
COPY --from=build ${BIN_DIR} ${BIN_DIR}

# # do multiple things
RUN --mount=type=cache,target=/var/cache/apk <<EOT
# # install ca-certificates
apk update
apk upgrade
apk add --no-cache ca-certificates=20240226-r0
# # create USER:GROUP
addgroup -G ${GROUP_ID} ${GROUP}
adduser -u ${USER_ID} -G ${GROUP_ID} -h /home/cosmopolitan -D ${USER}
chown ${USER_ID}:${GROUP_ID} -R -v ${BIN_DIR}
# # normalize the binary to ELF
redbean --assimilate
EOT

# # switch to the USER:GROUP
USER ${USER_ID}:${GROUP_ID}

# # switch to the working directory
WORKDIR /home/${USER}

# # start redbean when running the container
ENTRYPOINT [ "redbean" ]
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ help:
@echo " lint-dockerfile FILE"
@echo " lint-all"
@echo " redbean-build"
@echo " redbean-alpine"


# # # Default goal
Expand All @@ -41,6 +42,12 @@ redbean-build:
--build-arg=DEBIAN_TAG=$(DEBIAN_TAG) \
--build-arg=MODE=$(MODE)

redbean-alpine: redbean-build
DOCKER_BUILDKIT=1 docker buildx build $(CURDIR) \
--tag=redbean:$(REDBEAN_VERSION)-alpine \
--file=$(CURDIR)/Dockerfile.redbean-alpine \
--build-arg=ALPINE_TAG=$(ALPINE_TAG)


# # # Lint the Dockerfile

Expand Down

0 comments on commit fec315b

Please sign in to comment.