Last active
March 23, 2023 18:33
-
-
Save evzpav/ededee4327055d99ea6f886679829b78 to your computer and use it in GitHub Desktop.
Gitlab CI config for Dokku project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- deploy | |
variables: | |
APP_NAME: app-name | |
GIT_DEPTH: 0 | |
deploy: | |
stage: deploy | |
image: ilyasemenov/gitlab-ci-git-push | |
environment: | |
name: production | |
only: | |
- main | |
script: | |
- git-push ssh://dokku@$VM_IP:22/$APP_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---- Base Node ---- | |
FROM node:12-stretch-slim AS base | |
ENV NODE_ENV=development | |
RUN mkdir /app && chown -R node:node /app | |
RUN mkdir /app/vue-client && chown -R node:node /app/vue-client | |
WORKDIR /app | |
USER node | |
RUN npm set progress=false && npm config set depth 0 | |
# ---- Audit ---- | |
FROM base AS audit | |
COPY --chown=node:node package*.json ./ | |
RUN npm audit | |
# ---- Dependencies ---- | |
FROM base AS server-dependencies | |
WORKDIR /app | |
COPY --chown=node:node package*.json ./ | |
RUN npm ci --production && npm cache clean --force | |
# #---- Test ---- | |
FROM server-dependencies AS test | |
RUN npm ci --development | |
COPY --chown=node:node ./server ./server | |
RUN npm test | |
# ---- Frontend Dependencies ---- | |
FROM base AS front-dependencies | |
WORKDIR /app/vue-client | |
COPY --chown=node:node ./vue-client/package*.json ./ | |
RUN npm ci && npm cache clean --force | |
# ---- Front ---- | |
FROM front-dependencies AS front | |
WORKDIR /app/vue-client | |
COPY --chown=node:node ./vue-client ./ | |
RUN npm run build | |
# ---- Release ---- | |
FROM server-dependencies AS release | |
WORKDIR /app | |
COPY --chown=node:node --from=front /app/vue-client/build ./vue-client/build | |
COPY --chown=node:node ./server ./server | |
ENV NODE_ENV=production | |
CMD [ "node","server/server.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ssh-keygen -t rsa
dokku ssh-keys:add gitlabkey ~/.ssh/id_rsa.pub
SSH_PRIVATE_KEY (The private key generated in the Dokku machine:
cat ~/.ssh/id_rsa
)VM_IP (IP of the Dokku machine)