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

Alpine Docker image #106

Closed
camo-f opened this issue Oct 30, 2019 · 5 comments
Closed

Alpine Docker image #106

camo-f opened this issue Oct 30, 2019 · 5 comments
Assignees
Labels

Comments

@camo-f
Copy link
Contributor

camo-f commented Oct 30, 2019

Hello,

Here is my Dockerfile to use Alpine Linux instead of Debian and build in a container. I ended up with an ~83MB image.

FROM node:11-alpine AS build

RUN apk add -U --no-cache build-base # Add git to run git commands in make
COPY . /salty-dog
WORKDIR /salty-dog
RUN make

FROM node:11-alpine

# copy config, which changes rarely
COPY docs/config-docker.yml /root/.salty-dog.yml

# copy package first, to invalidate other layers when version changes
COPY package.json /salty-dog/package.json

# copy chunks, largest to smallest (entrypoint)
COPY --from=build /salty-dog/out/vendor.js /salty-dog/out/vendor.js
COPY --from=build /salty-dog/out/main.js /salty-dog/out/main.js
COPY --from=build /salty-dog/out/index.js /salty-dog/out/index.js

# set up as global cli tool
WORKDIR /salty-dog
RUN yarn global add file:$(pwd)
ENV PATH="${PATH}:$(yarn global bin)"

COPY rules /salty-dog/rules

ENTRYPOINT [ "node", "/salty-dog/out/index.js" ]
CMD [ "--help" ]

It also implies minor changes to test-examples.sh to make it shell compliant.

Do you see any problem moving to Alpine ? If any, we may simply add a new image with a specific tag alpine.
I can make a PR if you want.

@ssube
Copy link
Owner

ssube commented Oct 30, 2019

Hi, thanks for the suggestion! I have no problems adding an Alpine image, and your Dockerfile looks good - will give it a try later and fix up test-examples.sh as needed. I'd like to keep a stretch image (run a deb/ubuntu-based env as much as possible), so there will be a small CI tweak to build both and add the -alpine suffix, but I can make that.

Feel free to PR the Dockerfile by itself or with the script fixes, and I'll get it into CI and tag a release.

We may also be able to leave test-examples.sh as-is by reusing the bundle from the build-node job in CI, which has already run those tests. That won't help with local builds, however. 🤔

@camo-f
Copy link
Contributor Author

camo-f commented Oct 31, 2019

It seems to work when building with Stretch and then running in Alpine. Is it what you're doing during CI ?
If we want to use Alpine for build, we need to add build-base package in the image since make is not installed by default.
If we can keep Stretch for build, updating test-examples was indeed not necessary, but it is minor changes.

For local builds with Docker :

# Stretch
docker run --rm -v "$(pwd):/salty-dog" -w /salty-dog node:11-stretch make
docker build -t salty-dog:stretch -f Dockerfile.stretch .
# Alpine
docker run --rm -v "$(pwd):/salty-dog" -w /salty-dog node:11-alpine sh -c "apk add build-base && make"
docker build -t salty-dog:alpine -f Dockerfile.alpine .

Maybe we could add the instructions to the readme ?

@ssube
Copy link
Owner

ssube commented Oct 31, 2019

Yep, reusing the stretch-built files is exactly what I meant. Thanks for the PR, I've merged your changes and built an image from this branch: https://hub.docker.com/r/ssube/salty-dog/tags?page=1&name=alpine (it's tagged with branch-slug-alpine until I merge to master). Passes the tests and looks good to me, if you agree I will get it released.

@ssube ssube added the status/progress issues that are in progress label Oct 31, 2019
@camo-f
Copy link
Contributor Author

camo-f commented Nov 1, 2019

Seems ready for release to me. Thank you !

@ssube
Copy link
Owner

ssube commented Nov 1, 2019

Merged, tagged, and built.

@ssube ssube closed this as completed Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants