-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (63 loc) · 2.46 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (63 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
FROM archlinux:latest AS base
ARG PACMAN_MIRROR=
ARG NPM_MIRROR=
ARG GOPROXY=
ENV GOPROXY=$GOPROXY
RUN if [ -n "$PACMAN_MIRROR" ]; then \
printf 'Server = %s\n' "$PACMAN_MIRROR" > /etc/pacman.d/mirrorlist; \
fi
FROM base AS web
RUN pacman -Syu --noconfirm --needed nodejs npm \
&& pacman -Scc --noconfirm
WORKDIR /src/web
COPY web/package*.json ./
COPY web/src-pwa/package*.json ./src-pwa/
RUN if [ -n "$NPM_MIRROR" ]; then npm config set registry "$NPM_MIRROR"; fi \
&& npm ci --ignore-scripts \
&& npm --prefix src-pwa ci --ignore-scripts
COPY web/ ./
COPY internal/interfaces/http/static/ /src/internal/interfaces/http/static/
RUN npm run build
FROM base AS build
ARG ANYCODE_VERSION=dev
RUN pacman -Syu --noconfirm --needed ca-certificates go git \
&& pacman -Scc --noconfirm
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY cmd/ ./cmd/
COPY internal/ ./internal/
COPY --from=web /src/internal/interfaces/http/static/pwa ./internal/interfaces/http/static/pwa
RUN go build -ldflags "-X main.version=${ANYCODE_VERSION}" -o /out/anycode ./cmd/anycode
FROM base
ARG ANYCODE_UID=1000
ARG ANYCODE_GID=1000
ARG NPM_MIRROR=
ENV ANYCODE_UID=$ANYCODE_UID
ENV ANYCODE_GID=$ANYCODE_GID
ENV NVM_DIR=/usr/local/nvm
ENV NVM_SYMLINK_CURRENT=true
ENV PATH=/usr/local/nvm/current/bin:$PATH
RUN pacman -Syu --noconfirm --needed base-devel ca-certificates git bash nvm wget ripgrep p7zip openssh less \
go cloudflared ttf-dejavu catatonit \
&& pacman -Scc --noconfirm \
&& . /usr/share/nvm/init-nvm.sh \
&& nvm install node \
&& nvm alias default node \
&& if [ -n "$NPM_MIRROR" ]; then \
npm config set registry "$NPM_MIRROR" ;\
fi \
&& npm install -g @openai/codex@latest \
&& npm cache clean --force \
&& groupadd --gid "$ANYCODE_GID" anycode \
&& useradd --uid "$ANYCODE_UID" --gid anycode --create-home --home-dir /home/anycode --shell /bin/bash anycode \
&& install -d -o anycode -g anycode /app /workspaces /home/anycode/.anycode /home/anycode/.codex \
&& git config --system --add safe.directory '/workspaces/*'
WORKDIR /app
COPY --from=build --chown=anycode:anycode --chmod=0755 /out/anycode /usr/local/bin/anycode
COPY --chmod=0755 docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENV HOME=/home/anycode
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD addr="${ANYCODE_HTTP_ADDR:-:8080}"; wget -qO- "http://127.0.0.1${addr}/healthz" >/dev/null || exit 1
ENTRYPOINT ["/usr/bin/catatonit", "--", "/usr/local/bin/docker-entrypoint.sh"]
CMD ["anycode"]