Skip to content

Commit

Permalink
ci: Fixed dockerfile node installation
Browse files Browse the repository at this point in the history
  • Loading branch information
bahattincinic committed May 31, 2024
1 parent 702def5 commit 740ae39
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ WORKDIR /static

# https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported
ENV NODE_OPTIONS=--openssl-legacy-provider
# Install npm (with latest nodejs)
RUN apk add --update nodejs npm && \
npm i -g -s --unsafe-perm

# Update repositories and install npm (with latest nodejs)
RUN apk update && apk add --no-cache nodejs npm

# Log npm and node versions for debugging purposes
RUN node -v && npm -v

# Copy only ./ui folder to the working directory.
COPY ui .
Expand All @@ -30,27 +33,43 @@ FROM golang:1.18-alpine AS backend
# Move to a working directory (/build).
WORKDIR /build

# Install build dependencies
RUN apk add --no-cache gcc musl-dev

# Copy and download dependencies.
COPY go.mod go.sum ./
RUN go mod download

# Copy a source code to the container.
# Copy the source code to the container.
COPY . .

# Copy frontend static files from /static to the root folder of the backend container.
COPY --from=frontend ["/static/dist", "ui/dist"]
COPY --from=frontend /static/dist ui/dist

# Build the Go binary
RUN go build -tags=prod -o /build/fitwave ./cmd/fitwave

RUN make GCFLAGS="-tags=prod"
# Verify the binary is built
RUN ls -l /build/fitwave

#
# Third stage:
# Creating and running a new scratch container with the backend binary.
# Creating and running a new container with the backend binary.
#

FROM scratch
FROM alpine:3.17

# Install necessary runtime dependencies
RUN apk add --no-cache ca-certificates

# Copy binary from /build to the root folder of the container.
COPY --from=backend /build/fitwave /

# Verify the binary is copied correctly
RUN ls -l /fitwave

# Copy binary from /build to the root folder of the scratch container.
COPY --from=backend ["/build/fitwave", "/"]
# Expose the application port
EXPOSE 9000

# Command to run when starting the container.
ENTRYPOINT ["/fitwave"]

0 comments on commit 740ae39

Please sign in to comment.