Compare commits
	
		
			No commits in common. "eca82edf4fc791a4ce7012446eea63939133b00b" and "1887836c6e316c74c800bdaeb30bd2370d0c9dfb" have entirely different histories.
		
	
	
		
			eca82edf4f
			...
			1887836c6e
		
	
		
					 2 changed files with 6 additions and 21 deletions
				
			
		
							
								
								
									
										4
									
								
								Justfile
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								Justfile
									
										
									
									
									
								
							| 
						 | 
					@ -6,7 +6,6 @@ build-container-release:
 | 
				
			||||||
# Builds a release container and runs it
 | 
					# Builds a release container and runs it
 | 
				
			||||||
start-release: build-container-release remove-podman-containers
 | 
					start-release: build-container-release remove-podman-containers
 | 
				
			||||||
    podman run -d -e DATABASE_URL=sqlite:release.db -p 8080:8080 --name ttime ttime-server
 | 
					    podman run -d -e DATABASE_URL=sqlite:release.db -p 8080:8080 --name ttime ttime-server
 | 
				
			||||||
    @echo "Started production ttime-server on http://localhost:8080"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Removes and stops any containers related to the project
 | 
					# Removes and stops any containers related to the project
 | 
				
			||||||
[private]
 | 
					[private]
 | 
				
			||||||
| 
						 | 
					@ -15,7 +14,7 @@ remove-podman-containers:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Saves the release container to a tarball, pigz is just gzip but multithreaded
 | 
					# Saves the release container to a tarball, pigz is just gzip but multithreaded
 | 
				
			||||||
save-release: build-container-release
 | 
					save-release: build-container-release
 | 
				
			||||||
    podman save --format=oci-archive ttime-server | pigz -9 > ttime-server.tar.gz
 | 
					    podman save --format=oci-archive ttime-server | pigz -9 > ttime-server-pigz.tar.gz
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Loads the release container from a tarball
 | 
					# Loads the release container from a tarball
 | 
				
			||||||
load-release file:
 | 
					load-release file:
 | 
				
			||||||
| 
						 | 
					@ -26,6 +25,5 @@ clean: remove-podman-containers
 | 
				
			||||||
    podman image rm -f ttime-server
 | 
					    podman image rm -f ttime-server
 | 
				
			||||||
    rm -rf frontend/dist
 | 
					    rm -rf frontend/dist
 | 
				
			||||||
    rm -rf frontend/node_modules
 | 
					    rm -rf frontend/node_modules
 | 
				
			||||||
    rm ttime-server.tar.gz
 | 
					 | 
				
			||||||
    cd backend && make clean
 | 
					    cd backend && make clean
 | 
				
			||||||
    @echo "Cleaned up!"
 | 
					    @echo "Cleaned up!"
 | 
				
			||||||
| 
						 | 
					@ -2,39 +2,26 @@
 | 
				
			||||||
# We use node:latest as the base image.
 | 
					# We use node:latest as the base image.
 | 
				
			||||||
# Essentially we build the frontend SPA with vite and 
 | 
					# Essentially we build the frontend SPA with vite and 
 | 
				
			||||||
# make it available in the public directory.
 | 
					# make it available in the public directory.
 | 
				
			||||||
FROM docker.io/node:alpine as client
 | 
					FROM docker.io/node:latest as client
 | 
				
			||||||
WORKDIR /build
 | 
					WORKDIR /build
 | 
				
			||||||
ADD frontend /build
 | 
					ADD frontend /build
 | 
				
			||||||
RUN npm install
 | 
					RUN npm install
 | 
				
			||||||
RUN npm run build
 | 
					RUN npm run build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Builds the server in an isolated stage
 | 
					# Builds the server in an isolated stage
 | 
				
			||||||
FROM docker.io/golang:alpine as go
 | 
					FROM docker.io/golang:latest as go
 | 
				
			||||||
RUN apk add gcompat
 | 
					 | 
				
			||||||
RUN apk add gcc
 | 
					 | 
				
			||||||
RUN apk add musl-dev
 | 
					 | 
				
			||||||
ADD backend /build
 | 
					ADD backend /build
 | 
				
			||||||
WORKDIR /build
 | 
					WORKDIR /build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Copy the frontend SPA build into public
 | 
				
			||||||
 | 
					COPY --from=client /build/dist /build/static
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Get the dependencies
 | 
					# Get the dependencies
 | 
				
			||||||
RUN go mod download
 | 
					RUN go mod download
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# RUN go build -o server
 | 
					# RUN go build -o server
 | 
				
			||||||
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o ./server ./cmd/
 | 
					RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o ./server ./cmd/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# The final stage for building a minimal image
 | 
					 | 
				
			||||||
FROM docker.io/alpine:latest as runner
 | 
					 | 
				
			||||||
WORKDIR /app
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Copy the frontend SPA build into public
 | 
					 | 
				
			||||||
COPY --from=client /build/dist /app/static
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Copy the server binary
 | 
					 | 
				
			||||||
COPY --from=go /build/server /app/server
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Copy the migration scripts
 | 
					 | 
				
			||||||
COPY --from=go /build/migrations /app/migrations
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Expose port 8080
 | 
					# Expose port 8080
 | 
				
			||||||
EXPOSE 8080
 | 
					EXPOSE 8080
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue