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

Add Docker support #83

Closed
justb4 opened this issue Jul 16, 2019 · 5 comments
Closed

Add Docker support #83

justb4 opened this issue Jul 16, 2019 · 5 comments

Comments

@justb4
Copy link
Collaborator

justb4 commented Jul 16, 2019

Also given the configuration convention coming with Wegue, a Dockerfile that runs Wegue built for/in production mode would be beneficial to users. Especially re-using that Image for custom configs that may be applied via Docker Volume Mapping, directly (-v) or through a Docker Compose file.

A minimal Wegue Dockerfile will be the first step. Already tested with a minimally-sized (35MB) Image based on node:lts-alpine as builder. Can do a PR for this as well.

@chrismayer
Copy link
Collaborator

Totally agree that it would be cool to have Docker support for Wegue (applications). I also did some rough experiments on that.
The general idea of mine was to have a docker image with a Wegue production build in it (either build on image creation or copied / mounted) and a mount for JSON-app-config files. Also a web-server delivering the Wegue app should be part of it. A lightweight image (like alpine as you suggested) would be preferable.

I started with a nginx base image. But did not come as far as I wanted (due to lack of time). Since I am not Docker expert I am totally open for other approaches and would be happy if you could come up with a suggestion / draft for a Dockerfile.

@justb4
Copy link
Collaborator Author

justb4 commented Jul 16, 2019

Actually it was quite simple,lending from the official Vue.js Docker example, this is the entire Dockerfile:

# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# production stage
FROM nginx:stable-alpine as production-stage
LABEL maintainer="Just van den Broecke <https://github.com/justb4>"
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

So what happens here is that first an Image is used for the Node production build (node:lts-alpine as build-stage). Subsequently another base image (nginx:stable-alpine) is used wherein just the build result (app/dist) is copied. This is a very common Docker-build pattern these days, called Multi-Staged Build. The big advantage is that you end up with a very clean/small deployment Image (around 35M) without all the Node cruft.

This worked, and to run custom configs one can use Volume Mapping or build a derived Image overwriting the default config JSON.

justb4 added a commit to justb4/wegue that referenced this issue Jul 18, 2019
justb4 added a commit to justb4/wegue that referenced this issue Jul 19, 2019
chrismayer added a commit that referenced this issue Jul 19, 2019
#83 add Dockerfile with some docu in README
@chrismayer
Copy link
Collaborator

chrismayer commented Jul 19, 2019

Since this is very cool, I decided to release a new version v0.9.0 and build a Docker image based on this, which is available at DockerHub now: https://hub.docker.com/r/meggsimum/wegue

Thanks for pushing this forward, @justb4! Very appreciated!

@justb4
Copy link
Collaborator Author

justb4 commented Jul 19, 2019

Welcome! Glad to contribute. Tip: it is also always good to have a latest Image on DockerHub which autobuilds from master branch.

@chrismayer
Copy link
Collaborator

it is also always good to have a latest Image on DockerHub which autobuilds from master branch.

I just enabled it this morning. See https://hub.docker.com/r/meggsimum/wegue/tags

justb4 added a commit to justb4/wegue that referenced this issue Jul 23, 2019
chrismayer added a commit that referenced this issue Jul 23, 2019
#83 adapt README for DockerHub Image availability
justb4 pushed a commit to Geolicious/wegue that referenced this issue May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants