simplify and optimize dockerfile (ref #14)

This commit is contained in:
Felix 2020-02-15 16:28:21 +01:00
parent 7703f42054
commit 37b82c8614
3 changed files with 14 additions and 42 deletions

View File

@ -1 +1,3 @@
node_modules
node_modules
.git
dist

View File

@ -1,37 +0,0 @@
image: framasoft/vuefs:latest
stages:
- deploy
pages:
stage: deploy
script:
- yarn install --pure-lockfile
- npm run build
- rm -r public/ && mv dist/ public/
artifacts:
paths:
- public
cache:
paths:
- node_modules/
production:
stage: deploy
script:
- yarn install --pure-lockfile
- npm run build
- rm -r public/ && mv dist/ public/
- mkdir "${HOME}/.ssh"
- chmod 700 "${HOME}/.ssh"
- echo -e "${DEPLOYEMENT_KNOWN_HOSTS}" > ${HOME}/.ssh/known_hosts;
- eval `ssh-agent -s`
- ssh-add <(echo "${DEPLOYEMENT_KEY}" | base64 --decode -i);
- cd public && echo "put -r ." | sftp ${DEPLOYEMENT_USER}@${DEPLOYEMENT_HOST}:../../web;
only:
refs:
- master
variables:
- $DEPLOYEMENT_KEY
- $DEPLOYEMENT_KNOWN_HOSTS
- $DEPLOYEMENT_USER
- $DEPLOYEMENT_HOST

View File

@ -1,4 +1,4 @@
FROM node:10-buster-slim as build-stage
FROM node:13-alpine as build-stage
WORKDIR /app
@ -6,12 +6,19 @@ COPY package.json .
RUN yarn install --pure-lockfile \
&& yarn cache clean
# TODO: copy only the required files here
COPY . .
COPY src/ src/
COPY public/ public/
COPY yarn.lock .
COPY .eslintrc.js .
# TODO: the build works fine with only the above files, does that mean we can delete everything else?
#COPY vue.config.js .
#COPY postcss.config.js .
#COPY .eslintrc .
RUN yarn run build
FROM nginx as production-stage
RUN mkdir /app
COPY --from=build-stage /app/dist /app