Skip to content

Commit

Permalink
build: Optimise Docker image size [DEV-2662] (#56)
Browse files Browse the repository at this point in the history
* Update package lock

* Update package

* Update .dockerignore

* Update .dockerignore

* Update .dockerignore

* Update Dockerfile
  • Loading branch information
ankurdotb authored May 24, 2023
1 parent 007a44f commit bc18eab
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 34 deletions.
8 changes: 5 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Skip unncecessary folders
node_modules/**
.github/**
docker/**
**/.git
**/.github
**/node_modules
**/docker
**/lib

# Skip unnecessary files
**/*.md
Expand Down
14 changes: 11 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,27 @@ RUN npm run build

FROM ghcr.io/logto-io/logto:1.3.1 as runner

# Set Node.js environment
ENV NODE_ENV=production

# Set working directory
WORKDIR /etc/logto

# Install pre-requisites
RUN apk update && \
apk add --no-cache bash ca-certificates

# Copy files from builder
COPY --from=builder /home/node/app /etc/logto/packages/connectors/connector-telegram

# Add entrypoint script
COPY docker/entrypoint.sh /etc/logto/entrypoint.sh

# Copy files from builder
COPY --from=builder /home/node/app/package*.json /home/node/app/*.svg /etc/logto/packages/connectors/connector-telegram/
COPY --from=builder /home/node/app/lib/ /etc/logto/packages/connectors/connector-telegram/lib/

# Install dependencies
RUN cd /etc/logto/packages/connectors/connector-telegram/ && \
npm ci

# Make entrypoint script executable
RUN chmod +x entrypoint.sh && \
# Create symlink from packages/core/connectors to packages/connectors
Expand Down
46 changes: 22 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"exports": "./lib/index.js",
"type": "module",
"files": [
"lib"
"lib",
"**/*.svg",
"LICENSE",
"package.json",
"README.md"
],
"scripts": {
"precommit": "lint-staged",
Expand Down Expand Up @@ -70,9 +74,6 @@
"supertest": "^6.3.3",
"typescript": "^5.0.4"
},
"engines": {
"node": "^16.13.0 || ^18.12.0"
},
"eslintConfig": {
"extends": "@silverhand"
},
Expand Down

0 comments on commit bc18eab

Please sign in to comment.