Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use binary in slim docker image #13

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,8 @@ RUN cd /app/ \
## ##
###########################################################


# Official Bun image
FROM oven/bun:${BUN_VERSION} as automation-prod

# Bun uses NODE_ENV for backward compatibility with Node
ENV NODE_ENV="production"

# Simplicity first
WORKDIR /app
# Must be compatible with executable from Builder
FROM debian:buster-slim

# Open Container Initiative (OCI) labels
LABEL org.opencontainers.image.title="Automation Standalone" \
Expand All @@ -91,11 +84,12 @@ LABEL org.opencontainers.image.title="Automation Standalone" \
org.opencontainers.image.authors="Webber Takken <[email protected]>" \
org.opencontainers.image.licenses="MIT"

# Simplicity first
WORKDIR /app

# Copy the distributable files and production specific dependencies
COPY --from=builder /app/dist /app/package.json ./
COPY --from=builder /app/node_modules node_modules

# Run the app
USER bun
EXPOSE 3000
ENTRYPOINT [ "bun", "run", "server.js" ]
CMD ["./server"]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dev": "bun --hot --watch src/main.ts",
"sync": "yarn up \"@digital-alchemy/*\" && bunx --env-file .env type-writer",
"build": "bun --env-file .env build:docker",
"build:dist": "bun build src/main.ts --target=bun --outfile=dist/server.js",
"build:dist": "bun build src/main.ts --compile --minify --outfile dist/server",
"build:docker": "docker build . --build-arg HASS_TOKEN=$HASS_TOKEN --build-arg HASS_BASE_URL=$HASS_BASE_URL -t automation-prod",
"start": "docker run --env-file .env automation-prod",
"test": "vitest",
Expand Down