-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34587d6
commit d33565e
Showing
4 changed files
with
67 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
FROM golang:1.19-alpine | ||
# First stage: Build the Go application | ||
FROM golang:alpine AS build | ||
|
||
WORKDIR /usr/src/app | ||
# Set the working directory | ||
WORKDIR /app | ||
|
||
RUN apk add --no-cache git | ||
|
||
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change | ||
# Copy go.mod and go.sum | ||
COPY go.mod go.sum ./ | ||
|
||
# Download dependencies | ||
RUN go mod download && go mod verify | ||
|
||
# Copy the rest of the application files | ||
COPY . . | ||
RUN go build -v -o /usr/local/bin/app ./cmd/sxcctw_api/ \ | ||
&& go clean -fuzzcache \ | ||
&& go clean -testcache \ | ||
&& go clean -modcache | ||
|
||
CMD ["app"] | ||
# Build the application | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/bin/app ./cmd/sxcctw_api/ | ||
|
||
# Second stage: Serve the Go application | ||
FROM alpine | ||
|
||
# Copy the built binary from the build stage | ||
COPY --from=build /go/bin/app /go/bin/app | ||
|
||
# Start the Go application | ||
CMD ["/go/bin/app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
FROM golang:1.19-alpine | ||
# First stage: Build the Go application | ||
FROM golang:alpine AS build | ||
|
||
WORKDIR /usr/src/app | ||
# Set the working directory | ||
WORKDIR /app | ||
|
||
RUN apk add --no-cache git | ||
|
||
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change | ||
# Copy go.mod and go.sum | ||
COPY go.mod go.sum ./ | ||
|
||
# Download dependencies | ||
RUN go mod download && go mod verify | ||
|
||
# Copy the rest of the application files | ||
COPY . . | ||
RUN go build -v -o /usr/local/bin/app ./cmd/sxcctw_db/ \ | ||
&& go clean -fuzzcache \ | ||
&& go clean -testcache \ | ||
&& go clean -modcache | ||
|
||
CMD ["app"] | ||
# Build the application | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/bin/app ./cmd/sxcctw_db/ | ||
|
||
# Second stage: Serve the Go application | ||
FROM alpine | ||
|
||
# Copy the built binary from the build stage | ||
COPY --from=build /go/bin/app /go/bin/app | ||
|
||
# Start the Go application | ||
CMD ["/go/bin/app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
FROM node:alpine | ||
# First stage: Build the application | ||
FROM node:alpine AS build | ||
|
||
ARG WORKPLACE=/sxcctw-web | ||
ENV WEBPORT=$WEBPORT | ||
# Install pnpm globally | ||
RUN npm install -g pnpm | ||
|
||
COPY ./web $WORKPLACE | ||
# Set the working directory | ||
WORKDIR /app | ||
|
||
WORKDIR $WORKPLACE | ||
# Copy package.json and pnpm-lock.yaml | ||
COPY package.json pnpm-lock.yaml ./ | ||
|
||
RUN npm i -g pnpm serve && \ | ||
SHELL="/bin/bash" pnpm setup && \ | ||
pnpm i --frozen-lockfile && \ | ||
pnpm build | ||
# Install dependencies | ||
RUN pnpm install --frozen-lockfile | ||
|
||
RUN mkdir ../to_rm && \ | ||
mv ./* ../to_rm && \ | ||
mv ../to_rm/dist ./ && \ | ||
rm -rf ../to_rm | ||
# Copy the rest of the application files | ||
COPY . . | ||
|
||
ENV NODE_ENV=production | ||
# Build the application | ||
RUN pnpm build | ||
|
||
# The default export port will be set to 3000. | ||
CMD ["serve", "-s", "dist"] | ||
# Second stage: Serve the application with NGINX | ||
FROM nginx:stable-alpine | ||
|
||
# Copy built files from the build stage to the NGINX html directory | ||
COPY --from=build /app/dist /usr/share/nginx/html | ||
|
||
# Copy an optional custom nginx configuration file if needed | ||
# COPY nginx.conf /etc/nginx/conf.d/default.conf | ||
|
||
# Expose port 80 | ||
EXPOSE 80 | ||
|
||
# Start NGINX | ||
CMD ["nginx", "-g", "daemon off;"] |