Skip to content

Commit

Permalink
build: Mutli-stage build and slim image for websocket container (#21954)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yann-J committed Nov 4, 2022
1 parent 7d1df3b commit 9832bbd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/docker_build_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ docker build --target lean \
--label "build_actor=${GITHUB_ACTOR}" \
.

#
# Build the "websocket" image
#
docker build \
-t "${REPO_NAME}-websocket:${SHA}" \
-t "${REPO_NAME}-websocket:${REFSPEC}" \
-t "${REPO_NAME}-websocket:${LATEST_TAG}" \
--label "sha=${SHA}" \
--label "built_at=$(date)" \
--label "target=lean" \
--label "build_actor=${GITHUB_ACTOR}" \
superset-websocket

#
# Build the dev image
#
Expand Down
25 changes: 20 additions & 5 deletions superset-websocket/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,28 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM node:16
FROM node:16-alpine as build

WORKDIR /home/superset-websocket

COPY . .
COPY . ./

RUN npm ci
RUN npm run build
RUN npm ci && \
npm run build

CMD ["npm", "start"]

FROM node:16-alpine

ENV NODE_ENV=production
WORKDIR /home/superset-websocket

COPY --from=build /home/superset-websocket/dist ./dist
COPY package*.json ./

# Only install production dependencies
RUN npm ci --omit=dev

# Don't run as root!
USER node

CMD [ "npm", "start" ]
2 changes: 1 addition & 1 deletion superset-websocket/package-lock.json

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

0 comments on commit 9832bbd

Please sign in to comment.