improve dockerfile
This commit is contained in:
+34
-31
@@ -1,42 +1,29 @@
|
|||||||
FROM golang:1.26-bookworm AS build-env
|
#
|
||||||
|
# Stage 1: build the embed bundle with pnpm.
|
||||||
|
#
|
||||||
|
# Uses the official pnpm image. Node is auto-downloaded by pnpm using the
|
||||||
|
# `devEngines.runtime` field in package.json (onFail: "download").
|
||||||
|
#
|
||||||
|
FROM ghcr.io/pnpm/pnpm:11 AS web-build
|
||||||
|
|
||||||
WORKDIR /usr/src/social-app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
# Node
|
#
|
||||||
ENV NODE_VERSION=24.19.0
|
# pnpm config
|
||||||
ENV NVM_DIR=/usr/share/nvm
|
#
|
||||||
|
ENV CI=1
|
||||||
# Go
|
# use the pnpm version specified in package.json
|
||||||
ENV GODEBUG="netdns=go"
|
ENV pnpm_config_pm_on_fail=download
|
||||||
ENV GOOS="linux"
|
|
||||||
ARG TARGETARCH
|
|
||||||
ENV GOARCH=${TARGETARCH:-amd64}
|
|
||||||
ENV CGO_ENABLED=1
|
|
||||||
ENV GOEXPERIMENT="loopvar"
|
|
||||||
|
|
||||||
# CI environment for pnpm
|
|
||||||
ENV CI=true
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
#
|
#
|
||||||
# Generate the JavaScript webpack. NOTE: this will change
|
# Generate the embed bundle. NOTE: this will change
|
||||||
#
|
#
|
||||||
RUN mkdir --parents $NVM_DIR && \
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
|
||||||
wget \
|
|
||||||
--output-document=/tmp/nvm-install.sh \
|
|
||||||
https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh && \
|
|
||||||
bash /tmp/nvm-install.sh
|
|
||||||
|
|
||||||
RUN \. "$NVM_DIR/nvm.sh" && \
|
|
||||||
nvm install $NODE_VERSION && \
|
|
||||||
nvm use $NODE_VERSION && \
|
|
||||||
npm install --global pnpm@11.21.0 && \
|
|
||||||
pnpm install --frozen-lockfile && \
|
|
||||||
cd bskyembed && pnpm install --frozen-lockfile && cd .. && \
|
cd bskyembed && pnpm install --frozen-lockfile && cd .. && \
|
||||||
pnpm intl:build && \
|
|
||||||
pnpm build-embed
|
pnpm build-embed
|
||||||
|
|
||||||
# DEBUG
|
# DEBUG
|
||||||
@@ -48,8 +35,21 @@ RUN touch bskyweb/static/css/empty.txt
|
|||||||
RUN touch bskyweb/static/media/empty.txt
|
RUN touch bskyweb/static/media/empty.txt
|
||||||
|
|
||||||
#
|
#
|
||||||
# Generate the embedr Go binary.
|
# Stage 2: build the embedr Go binary, embedding the assets from stage 1.
|
||||||
#
|
#
|
||||||
|
FROM golang:1.26-bookworm AS go-build
|
||||||
|
|
||||||
|
WORKDIR /usr/src/social-app
|
||||||
|
|
||||||
|
ENV GODEBUG="netdns=go"
|
||||||
|
ENV GOOS="linux"
|
||||||
|
ARG TARGETARCH
|
||||||
|
ENV GOARCH=${TARGETARCH:-amd64}
|
||||||
|
ENV CGO_ENABLED=1
|
||||||
|
ENV GOEXPERIMENT="loopvar"
|
||||||
|
|
||||||
|
COPY --from=web-build /app/bskyweb ./bskyweb
|
||||||
|
|
||||||
RUN cd bskyweb/ && \
|
RUN cd bskyweb/ && \
|
||||||
go mod download && \
|
go mod download && \
|
||||||
go mod verify
|
go mod verify
|
||||||
@@ -62,6 +62,9 @@ RUN cd bskyweb/ && \
|
|||||||
-o /embedr \
|
-o /embedr \
|
||||||
./cmd/embedr
|
./cmd/embedr
|
||||||
|
|
||||||
|
#
|
||||||
|
# Stage 3: runtime image.
|
||||||
|
#
|
||||||
FROM debian:bookworm-slim
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
ENV GODEBUG=netdns=go
|
ENV GODEBUG=netdns=go
|
||||||
@@ -75,7 +78,7 @@ RUN apt-get update && apt-get install --yes \
|
|||||||
ENTRYPOINT ["dumb-init", "--"]
|
ENTRYPOINT ["dumb-init", "--"]
|
||||||
|
|
||||||
WORKDIR /embedr
|
WORKDIR /embedr
|
||||||
COPY --from=build-env /embedr /usr/bin/embedr
|
COPY --from=go-build /embedr /usr/bin/embedr
|
||||||
|
|
||||||
CMD ["/usr/bin/embedr"]
|
CMD ["/usr/bin/embedr"]
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,21 @@
|
|||||||
"name": "bskyembed",
|
"name": "bskyembed",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=24.18.0"
|
||||||
|
},
|
||||||
|
"devEngines": {
|
||||||
|
"packageManager": {
|
||||||
|
"name": "pnpm",
|
||||||
|
"version": "11.21.0",
|
||||||
|
"onFail": "error"
|
||||||
|
},
|
||||||
|
"runtime": {
|
||||||
|
"name": "node",
|
||||||
|
"version": "^24.18.0",
|
||||||
|
"onFail": "download"
|
||||||
|
}
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"dev-snippet": "tsc --project tsconfig.snippet.json && serve -s dist -p 3000 -n",
|
"dev-snippet": "tsc --project tsconfig.snippet.json && serve -s dist -p 3000 -n",
|
||||||
|
|||||||
Generated
+126
@@ -51,6 +51,9 @@ importers:
|
|||||||
globals:
|
globals:
|
||||||
specifier: ^17.7.0
|
specifier: ^17.7.0
|
||||||
version: 17.7.0
|
version: 17.7.0
|
||||||
|
node:
|
||||||
|
specifier: runtime:^24.18.0
|
||||||
|
version: runtime:24.19.0
|
||||||
postcss:
|
postcss:
|
||||||
specifier: ^8.5.20
|
specifier: ^8.5.20
|
||||||
version: 8.5.20
|
version: 8.5.20
|
||||||
@@ -1966,6 +1969,127 @@ packages:
|
|||||||
resolution: {integrity: sha512-wRNIrw4DmVLKQlbgOMdkMx27Wrpzes2hh5Jtbi2bjPd+4wJstWIqP5A+lscnqbm0xxmT5Bpg8Lec5ItEBwx6BQ==}
|
resolution: {integrity: sha512-wRNIrw4DmVLKQlbgOMdkMx27Wrpzes2hh5Jtbi2bjPd+4wJstWIqP5A+lscnqbm0xxmT5Bpg8Lec5ItEBwx6BQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
|
node@runtime:24.19.0:
|
||||||
|
resolution:
|
||||||
|
type: variations
|
||||||
|
variants:
|
||||||
|
- resolution:
|
||||||
|
archive: tarball
|
||||||
|
bin:
|
||||||
|
node: bin/node
|
||||||
|
integrity: sha256-9ONcExZd5ogMqiVYwKpIyoitpH/iI0vtB9Ztu4CkfI0=
|
||||||
|
type: binary
|
||||||
|
url: https://nodejs.org/download/release/v24.19.0/node-v24.19.0-aix-ppc64.tar.gz
|
||||||
|
targets:
|
||||||
|
- cpu: ppc64
|
||||||
|
os: aix
|
||||||
|
- resolution:
|
||||||
|
archive: tarball
|
||||||
|
bin:
|
||||||
|
node: bin/node
|
||||||
|
integrity: sha256-gpS3qpsDmXSBwGur8eiycMhZNY8n2lehFQmv5TesOB0=
|
||||||
|
type: binary
|
||||||
|
url: https://nodejs.org/download/release/v24.19.0/node-v24.19.0-darwin-arm64.tar.gz
|
||||||
|
targets:
|
||||||
|
- cpu: arm64
|
||||||
|
os: darwin
|
||||||
|
- resolution:
|
||||||
|
archive: tarball
|
||||||
|
bin:
|
||||||
|
node: bin/node
|
||||||
|
integrity: sha256-0bXpmdsVjGL+j3JnpEdrA12L2TsaYFusJKPw3RZuMxY=
|
||||||
|
type: binary
|
||||||
|
url: https://nodejs.org/download/release/v24.19.0/node-v24.19.0-darwin-x64.tar.gz
|
||||||
|
targets:
|
||||||
|
- cpu: x64
|
||||||
|
os: darwin
|
||||||
|
- resolution:
|
||||||
|
archive: tarball
|
||||||
|
bin:
|
||||||
|
node: bin/node
|
||||||
|
integrity: sha256-0oyKW/CoCPDtQ0odzoxUrpjwNxwL2GrFirxhP3PmZD8=
|
||||||
|
type: binary
|
||||||
|
url: https://nodejs.org/download/release/v24.19.0/node-v24.19.0-linux-arm64.tar.gz
|
||||||
|
targets:
|
||||||
|
- cpu: arm64
|
||||||
|
os: linux
|
||||||
|
- resolution:
|
||||||
|
archive: tarball
|
||||||
|
bin:
|
||||||
|
node: bin/node
|
||||||
|
integrity: sha256-sxqMTLxYn5FS8y/bQxhGl1nhZViltdk7f/L7KHsBPbI=
|
||||||
|
type: binary
|
||||||
|
url: https://nodejs.org/download/release/v24.19.0/node-v24.19.0-linux-ppc64le.tar.gz
|
||||||
|
targets:
|
||||||
|
- cpu: ppc64le
|
||||||
|
os: linux
|
||||||
|
- resolution:
|
||||||
|
archive: tarball
|
||||||
|
bin:
|
||||||
|
node: bin/node
|
||||||
|
integrity: sha256-s6tqQ5KCjbn9TtloOY1VGIKSvMFYGVQtU74LEQDjMvw=
|
||||||
|
type: binary
|
||||||
|
url: https://nodejs.org/download/release/v24.19.0/node-v24.19.0-linux-s390x.tar.gz
|
||||||
|
targets:
|
||||||
|
- cpu: s390x
|
||||||
|
os: linux
|
||||||
|
- resolution:
|
||||||
|
archive: tarball
|
||||||
|
bin:
|
||||||
|
node: bin/node
|
||||||
|
integrity: sha256-9iXZfNcH30/5YlSRb7xf8BTwnAnv/loeDKj21BqHidQ=
|
||||||
|
type: binary
|
||||||
|
url: https://nodejs.org/download/release/v24.19.0/node-v24.19.0-linux-x64.tar.gz
|
||||||
|
targets:
|
||||||
|
- cpu: x64
|
||||||
|
os: linux
|
||||||
|
- resolution:
|
||||||
|
archive: zip
|
||||||
|
bin:
|
||||||
|
node: node.exe
|
||||||
|
integrity: sha256-hQL0pQtFjUzDjtjyABVWws0jnUZJIPdAF5Jsyx4cFX8=
|
||||||
|
prefix: node-v24.19.0-win-arm64
|
||||||
|
type: binary
|
||||||
|
url: https://nodejs.org/download/release/v24.19.0/node-v24.19.0-win-arm64.zip
|
||||||
|
targets:
|
||||||
|
- cpu: arm64
|
||||||
|
os: win32
|
||||||
|
- resolution:
|
||||||
|
archive: zip
|
||||||
|
bin:
|
||||||
|
node: node.exe
|
||||||
|
integrity: sha256-V/cas2UueX2ErN3HnIHMn/HG3bKhl0zbg/AP7pv/THM=
|
||||||
|
prefix: node-v24.19.0-win-x64
|
||||||
|
type: binary
|
||||||
|
url: https://nodejs.org/download/release/v24.19.0/node-v24.19.0-win-x64.zip
|
||||||
|
targets:
|
||||||
|
- cpu: x64
|
||||||
|
os: win32
|
||||||
|
- resolution:
|
||||||
|
archive: tarball
|
||||||
|
bin:
|
||||||
|
node: bin/node
|
||||||
|
integrity: sha256-IIJOTTWUj65bM33M70eBOwTYmVMS9Z33OG8iVtn5q34=
|
||||||
|
type: binary
|
||||||
|
url: https://unofficial-builds.nodejs.org/download/release/v24.19.0/node-v24.19.0-linux-arm64-musl.tar.gz
|
||||||
|
targets:
|
||||||
|
- cpu: arm64
|
||||||
|
os: linux
|
||||||
|
libc: musl
|
||||||
|
- resolution:
|
||||||
|
archive: tarball
|
||||||
|
bin:
|
||||||
|
node: bin/node
|
||||||
|
integrity: sha256-xgIjeG3xSl0j4iDruOYDGPUyJkCmL5Dm2eVNOhjaUy4=
|
||||||
|
type: binary
|
||||||
|
url: https://unofficial-builds.nodejs.org/download/release/v24.19.0/node-v24.19.0-linux-x64-musl.tar.gz
|
||||||
|
targets:
|
||||||
|
- cpu: x64
|
||||||
|
os: linux
|
||||||
|
libc: musl
|
||||||
|
version: 24.19.0
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
normalize-path@3.0.0:
|
normalize-path@3.0.0:
|
||||||
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
|
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@@ -4536,6 +4660,8 @@ snapshots:
|
|||||||
|
|
||||||
node-releases@2.0.51: {}
|
node-releases@2.0.51: {}
|
||||||
|
|
||||||
|
node@runtime:24.19.0: {}
|
||||||
|
|
||||||
normalize-path@3.0.0: {}
|
normalize-path@3.0.0: {}
|
||||||
|
|
||||||
npm-run-path@4.0.1:
|
npm-run-path@4.0.1:
|
||||||
|
|||||||
Reference in New Issue
Block a user