-
-
Notifications
You must be signed in to change notification settings - Fork 427
feat: Add Dockerize option to nuxt project #581
base: main
Are you sure you want to change the base?
Changes from all commits
6183aab
16be1d9
767be52
100aff4
4d7117c
c76e8a6
341a3b6
c7cb574
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Dockerfile | ||
FROM node:14-alpine | ||
|
||
# create destination directory | ||
RUN mkdir -p /app | ||
WORKDIR /app | ||
|
||
# update and install dependency | ||
RUN apk update && apk upgrade | ||
RUN apk add git | ||
|
||
# install packages | ||
COPY package.json . | ||
COPY yarn.lock . | ||
RUN yarn install | ||
|
||
# copy project to directory | ||
COPY . . | ||
RUN yarn build | ||
|
||
EXPOSE 80 | ||
ENV NUXT_PORT=80 | ||
ENV HOST 0.0.0.0 | ||
|
||
CMD [ "yarn", "start" ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: '3.7' | ||
|
||
services: | ||
app: | ||
build: . | ||
image: <%= name %>/<%= name %> | ||
container_name: <%= name %> | ||
restart: always |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,5 +112,15 @@ module.exports = [ | |
{ name: 'Semantic Pull Requests', value: 'semantic-pull-requests' } | ||
], | ||
default: [] | ||
}, | ||
{ | ||
name: 'devOps', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may need to somehow enable it only for server target since for full static doesn't makes sense having this option There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The selection of this feature is optional and also due to the code structure, it is not possible to enable this feature based on the condition. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There most certainly are use-cases for deploying full static sites as Dockerized, which except for using nginx itself include also scenarios like using a reverse proxy to expose private services inside a k8s cluster (and possibly whitelisting/blacklisting their endpoints) when the site consumes their API, or to go around CORS issues if the APIs cannot be accessed directly (though in some cases https://axios.nuxtjs.org/options/#proxy may be used for this, but it can't be used if we "already" use nginx anyway) This seems to be officially suggested by Nuxt at https://nuxtjs.org/docs/2.x/deployment/nginx-proxy However, note that nginx has some major issues when using it as a reverse proxy for other services; for example it doesn't support |
||
message: 'DevOps tools:', | ||
type: 'list', | ||
choices: [ | ||
{ name: 'None', value: 'none' }, | ||
{ name: 'Docker', value: 'docker' } | ||
], | ||
default: 'none' | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alpine version is a very small version. I have been using this config for a long time and it can install packages well, the only problem is that it does not have git by default, which is when we use a package that instead of npm from use git, to solve this problem, I install git manually.
I have also seen some users have problems because the output size of the container with the image node itself is large.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in this case, if you know something better, I'll be happy for you to share so we can replace it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok using alpine by default,. Maybe we can add a comment like
# FROM node:14
to quickly switch? :)Using single stage, ends up with final image with full dependencies in intermediate layers (including all devDependencies like webpack). (read more)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alpine > *
also, at geospoc we use nginx to serve as it provides nice brotli support out-of-the-box,
this is a huge change on how deployment of nuxt apps work..
PS. this is the Dockerfile we use at GeoSpoc
staged builds for life!