docker build
This commit is contained in:
+25
-12
@@ -1,17 +1,30 @@
|
|||||||
stages:
|
stages:
|
||||||
- lint
|
- build
|
||||||
|
- push
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
NODE_OPTIONS: "--openssl-legacy-provider"
|
DOCKER_DRIVER: overlay2
|
||||||
|
DOCKER_TLS_CERTDIR: ""
|
||||||
|
DOCKER_HOST: tcp://docker:2375/
|
||||||
|
|
||||||
lint_frontend:
|
services:
|
||||||
stage: lint
|
- docker:dind
|
||||||
image: node:18-slim
|
|
||||||
before_script:
|
before_script:
|
||||||
- npm config set strict-ssl false
|
- docker info
|
||||||
|
|
||||||
|
build_container:
|
||||||
|
stage: build
|
||||||
|
image: docker:19.03.12
|
||||||
script:
|
script:
|
||||||
- cd notes-app
|
- docker build -t $CI_REGISTRY_IMAGE/my-container:latest .
|
||||||
- npm cache clean --force
|
- docker tag $CI_REGISTRY_IMAGE/my-container:latest $CI_REGISTRY_IMAGE/my-container:$CI_COMMIT_SHORT_SHA
|
||||||
- npm ci
|
|
||||||
- npm install eslint
|
push_container:
|
||||||
- npx eslint .
|
stage: push
|
||||||
|
image: docker:19.03.12
|
||||||
|
script:
|
||||||
|
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
|
||||||
|
- docker push $CI_REGISTRY_IMAGE/my-container:latest
|
||||||
|
- docker push $CI_REGISTRY_IMAGE/my-container:$CI_COMMIT_SHORT_SHA
|
||||||
|
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
#Front
|
||||||
|
FROM node:18-slim
|
||||||
|
WORKDIR /usr/local/app
|
||||||
|
COPY notes-app/package*.json ./
|
||||||
|
RUN npm i && npm cache clean --force
|
||||||
|
COPY notes-app/ .
|
||||||
|
RUN npm run build
|
||||||
|
#Backend
|
||||||
|
FROM node:18-slim
|
||||||
|
WORKDIR /usr/local/app
|
||||||
|
COPY notes-backend/package*.json ./
|
||||||
|
RUN npm i && npm cache clean --force
|
||||||
|
COPY notes-backend/ .
|
||||||
|
RUN npm run build
|
||||||
|
#nginx
|
||||||
|
FROM nginx:alpine
|
||||||
|
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY --from=build-react /app/build /usr/share/nginx/html
|
||||||
|
COPY --from=build-node /app/dist /usr/share/nginx/html/api
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|
||||||
Reference in New Issue
Block a user