This commit is contained in:
parent
8ae0a721fb
commit
680db6bbec
24
.gitea/workflows/deploy.yml
Normal file
24
.gitea/workflows/deploy.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
name: Deploy
|
||||||
|
run-name: ${{ gitea.actor }} build image and push to container registry
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
- 'staging'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
CreateImage:
|
||||||
|
runs-on: [hubstaging]
|
||||||
|
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/build-image.yml@v1.1.6-p
|
||||||
|
with:
|
||||||
|
runner: hubstaging
|
||||||
|
secrets:
|
||||||
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
DeployService:
|
||||||
|
runs-on: [hubstaging]
|
||||||
|
needs: CreateImage
|
||||||
|
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/deploy.yml@v1.1.4-p7
|
||||||
|
with:
|
||||||
|
runner: hubstaging
|
14
.gitea/workflows/lint.yml
Normal file
14
.gitea/workflows/lint.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: Lint
|
||||||
|
run-name: ${{ gitea.actor }} produce linting
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'dev'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Lint:
|
||||||
|
runs-on: [hubstaging]
|
||||||
|
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/lint.yml@v1.1.2
|
||||||
|
with:
|
||||||
|
runner: hubstaging
|
@ -1,29 +0,0 @@
|
|||||||
include:
|
|
||||||
- project: "devops/pena-continuous-integration"
|
|
||||||
file: "/templates/docker/build-template.gitlab-ci.yml"
|
|
||||||
- project: "devops/pena-continuous-integration"
|
|
||||||
file: "/templates/docker/deploy-template.gitlab-ci.yml"
|
|
||||||
|
|
||||||
build-app:
|
|
||||||
stage: build
|
|
||||||
tags:
|
|
||||||
- nodebuild
|
|
||||||
extends: .build_template
|
|
||||||
variables:
|
|
||||||
DOCKER_BUILD_PATH: "./Dockerfile"
|
|
||||||
PRODUCTION_BRANCH: main
|
|
||||||
STAGING_BRANCH: staging
|
|
||||||
|
|
||||||
deploy-to-staging:
|
|
||||||
tags:
|
|
||||||
- staging
|
|
||||||
rules:
|
|
||||||
- if: "$CI_COMMIT_BRANCH == $STAGING_BRANCH"
|
|
||||||
extends: .deploy_template
|
|
||||||
|
|
||||||
deploy-to-prod:
|
|
||||||
rules:
|
|
||||||
- if: "$CI_COMMIT_BRANCH == $PRODUCTION_BRANCH"
|
|
||||||
tags:
|
|
||||||
- prod
|
|
||||||
extends: .deploy_template
|
|
73
Dockerfile
73
Dockerfile
@ -1,64 +1,15 @@
|
|||||||
FROM node:20.5.1-alpine3.17 as build
|
FROM gitea.pena/penadevops/container-images/golang:main as build
|
||||||
|
|
||||||
# Update packages and clear cache
|
|
||||||
RUN apk update && rm -rf /var/cache/apk/*
|
|
||||||
# Set the working directory inside the container
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
# Add package metadata files
|
ENV GOPRIVATE=gitea.pena/PenaSide/common,gitea.pena/PenaSide/linters-golang,gitea.pena/PenaSide/customer,gitea.pena/PenaSide/trashlog,gitea.pena/PenaSide/hlog
|
||||||
ADD yarn.lock package.json tsconfig.json ./
|
ENV GOINSECURE=gitea.pena/PenaSide/common,gitea.pena/PenaSide/linters-golang,gitea.pena/PenaSide/customer,gitea.pena/PenaSide/trashlog,gitea.pena/PenaSide/hlog
|
||||||
# Add src folder
|
ENV GOPROXY=https://proxy.golang.org,direct
|
||||||
ADD src ./src/
|
ENV GOPATH=go-cache
|
||||||
# Add tools
|
COPY . .
|
||||||
ADD tools ./tools/
|
RUN go mod download
|
||||||
# Add migrations
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app
|
||||||
ADD migrations ./migrations
|
|
||||||
# Install packages
|
|
||||||
RUN yarn install --ignore-scripts --non-interactive && yarn cache clean
|
|
||||||
# Build app
|
|
||||||
RUN yarn build
|
|
||||||
|
|
||||||
|
FROM gitea.pena/penadevops/container-images/alpine:main
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
COPY --from=build app/app .
|
||||||
|
CMD ["/app"]
|
||||||
|
|
||||||
|
|
||||||
FROM node:20.5.1-alpine3.17 as test
|
|
||||||
|
|
||||||
# Update packages and clear cache
|
|
||||||
RUN apk update && rm -rf /var/cache/apk/*
|
|
||||||
# Set production env
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
# Set the working directory inside the container
|
|
||||||
WORKDIR /app
|
|
||||||
# Copy built files from build stage
|
|
||||||
COPY --from=build /app/dist /app/package.json /app/yarn.lock ./
|
|
||||||
# Copy migrate tool from build stage
|
|
||||||
COPY --from=build /app/tools/migrate /usr/local/bin/migrate
|
|
||||||
# Copy test migrations from build stage
|
|
||||||
COPY --from=build /app/migrations/test ./migrations
|
|
||||||
# Change ownership of files in the /app directory to the 'node' user
|
|
||||||
RUN chown -R node: .
|
|
||||||
# Install packages
|
|
||||||
RUN yarn install --non-interactive --frozen-lockfile --production && yarn cache clean
|
|
||||||
# Set 'node' user as the active user within the container
|
|
||||||
USER node
|
|
||||||
# Run the Node.js application
|
|
||||||
CMD ["node", "./index.js"]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FROM node:20.5.1-alpine3.17 as production
|
|
||||||
|
|
||||||
# Update packages and clear cache
|
|
||||||
RUN apk update && rm -rf /var/cache/apk/*
|
|
||||||
# Set production env
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
# Set the working directory inside the container
|
|
||||||
WORKDIR /app
|
|
||||||
# Copy built files from build stage
|
|
||||||
COPY --from=build /app/dist /app/package.json /app/yarn.lock ./
|
|
||||||
# Change ownership of files in the /app directory to the 'node' user
|
|
||||||
RUN chown -R node: .
|
|
||||||
# Install packages
|
|
||||||
RUN yarn install --non-interactive --frozen-lockfile --production && yarn cache clean
|
|
||||||
# Set 'node' user as the active user within the container
|
|
||||||
USER node
|
|
||||||
# Run the Node.js application
|
|
||||||
CMD ["node", "./index.js"]
|
|
Loading…
Reference in New Issue
Block a user