docker build
This commit is contained in:
+25
-12
@@ -1,17 +1,30 @@
|
||||
stages:
|
||||
- lint
|
||||
- build
|
||||
- push
|
||||
|
||||
variables:
|
||||
NODE_OPTIONS: "--openssl-legacy-provider"
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_HOST: tcp://docker:2375/
|
||||
|
||||
lint_frontend:
|
||||
stage: lint
|
||||
image: node:18-slim
|
||||
before_script:
|
||||
- npm config set strict-ssl false
|
||||
services:
|
||||
- docker:dind
|
||||
|
||||
before_script:
|
||||
- docker info
|
||||
|
||||
build_container:
|
||||
stage: build
|
||||
image: docker:19.03.12
|
||||
script:
|
||||
- cd notes-app
|
||||
- npm cache clean --force
|
||||
- npm ci
|
||||
- npm install eslint
|
||||
- npx eslint .
|
||||
- docker build -t $CI_REGISTRY_IMAGE/my-container:latest .
|
||||
- docker tag $CI_REGISTRY_IMAGE/my-container:latest $CI_REGISTRY_IMAGE/my-container:$CI_COMMIT_SHORT_SHA
|
||||
|
||||
push_container:
|
||||
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