Skip to content

Commit

Permalink
fix(user-storage): rebuild image
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoSkorJjj committed Apr 22, 2024
1 parent 12e1347 commit 1bc058f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/user-storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/simple/user-storage/
file: ./backend/simple/user-storage/Dockerfile
file: ./backend/simple/user-storage/UserStorage.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:user-storage
platforms: linux/arm64
70 changes: 70 additions & 0 deletions backend/simple/user-storage/UserStorage.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Base stage for protocol buffer compilation
FROM node:20.11.1 AS proto-base

# Set the working directory in the container
WORKDIR /app

# Copy buffer configuration files to the working directory
COPY buf.* .

# Copy package.json and package-lock.json (if available) to the working directory
COPY package*.json ./

# Install dependencies
RUN npm install

# Install buf globally
RUN npm install -g @bufbuild/buf

# Copy the Protobuf definitions to the working directory
COPY protos ./protos

# Generate code from Protobuf definitions
RUN buf generate

#####################

# Build stage for the application
FROM node:20.11.1 AS build

# Set the working directory in the container
WORKDIR /app

# Install curl, a command line tool and library for transferring data with URLs
RUN apt-get update && apt-get install -y curl

# Copy the node_modules directory and compiled protobuf files from the proto-base stage
COPY --from=proto-base /app/node_modules ./node_modules
COPY --from=proto-base /app/pb ./pb
COPY . .
# Compile the application
RUN npm run build

# Download and install the gRPC health probe, used for checking the health of gRPC applications
RUN GRPC_HEALTH_PROBE_VERSION=v0.4.13 && \
curl -sLo /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64 && \
chmod +x /bin/grpc_health_probe
#####################

# Final stage for running the application
FROM gcr.io/distroless/nodejs20-debian12

# Set the working directory in the container
WORKDIR /app

# Set the environment to production to optimize for production
ENV NODE_ENV production

# Copy compiled protobuf definitions to the container
COPY protos /app/dist/protos
COPY src/cert /app/dist/src/cert

# Copy the compiled application and its dependencies from the build stage
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules

# Copy the gRPC health probe to the container
COPY --from=build /bin/grpc_health_probe /bin/grpc_health_probe

# Command to run the application
CMD ["./dist/src/index.js"]

0 comments on commit 1bc058f

Please sign in to comment.