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
|
||||
|
||||
# Update packages and clear cache
|
||||
RUN apk update && rm -rf /var/cache/apk/*
|
||||
# Set the working directory inside the container
|
||||
FROM gitea.pena/penadevops/container-images/golang:main as build
|
||||
WORKDIR /app
|
||||
# Add package metadata files
|
||||
ADD yarn.lock package.json tsconfig.json ./
|
||||
# Add src folder
|
||||
ADD src ./src/
|
||||
# Add tools
|
||||
ADD tools ./tools/
|
||||
# Add migrations
|
||||
ADD migrations ./migrations
|
||||
# Install packages
|
||||
RUN yarn install --ignore-scripts --non-interactive && yarn cache clean
|
||||
# Build app
|
||||
RUN yarn build
|
||||
ENV GOPRIVATE=gitea.pena/PenaSide/common,gitea.pena/PenaSide/linters-golang,gitea.pena/PenaSide/customer,gitea.pena/PenaSide/trashlog,gitea.pena/PenaSide/hlog
|
||||
ENV GOINSECURE=gitea.pena/PenaSide/common,gitea.pena/PenaSide/linters-golang,gitea.pena/PenaSide/customer,gitea.pena/PenaSide/trashlog,gitea.pena/PenaSide/hlog
|
||||
ENV GOPROXY=https://proxy.golang.org,direct
|
||||
ENV GOPATH=go-cache
|
||||
COPY . .
|
||||
RUN go mod download
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app
|
||||
|
||||
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