lifi/.devcontainer/Dockerfile

40 lines
1.2 KiB
Docker

FROM golang:1-alpine AS build-listen
WORKDIR /usr/src/listen
RUN apk upgrade --no-cache && apk add --no-cache git
RUN git clone https://forge.steck.dev/bryson/listen .
RUN go build -ldflags "-s -w" .
FROM fedora:latest AS devcontainer
ARG UID="1000"
ARG GID="1000"
ARG BASENAME="workdir"
# setup packages
USER root
RUN dnf update -y
RUN dnf install -y dnf5-devel libdnf5-devel libdnf5-cli-devel openssh-server vim cmake gcc g++ git just
# setup environment
RUN ssh-keygen -A
RUN sed -i "s|#Port 22|Port 2222|g" /etc/ssh/sshd_config
RUN sed -i "s|AuthorizedKeysFile.*|AuthorizedKeysFile /etc/ssh/authorized_keys|g" /etc/ssh/sshd_config
RUN --mount=type=secret,id=key,target=/root/id.pub \
cp /root/id.pub /etc/ssh/authorized_keys
# setup user and permissions
RUN groupadd -g $GID dev
RUN useradd -u $UID -g $GID -lN dev
RUN chown dev:dev /etc/ssh/ssh_host* /etc/ssh/authorized_keys /etc/ssh/sshd_config
# copy data from other stages
COPY --from=build-listen /usr/src/listen/listen /usr/local/bin
# final configuration
USER dev
WORKDIR /volume/${BASENAME}
EXPOSE 2222/tcp
CMD ["/usr/sbin/sshd", "-D"]
# use docker exec or SSH to access container OR
# use docker compose to specify entrypoint