Add Dockerfile

This commit is contained in:
Thomas Miceli 2023-04-04 15:17:55 +02:00
parent b48f15690a
commit c3940933bb
No known key found for this signature in database
GPG key ID: D86C6F6390AF050F
4 changed files with 59 additions and 2 deletions

7
.dockerignore Normal file
View file

@ -0,0 +1,7 @@
node_modules/
gist.db
.idea/
.DS_Store
/**/.DS_Store
public/assets/*
public/manifest.json

43
Dockerfile Normal file
View file

@ -0,0 +1,43 @@
FROM alpine:3.17
# Install required dependencies
RUN apk update && \
apk add --no-cache \
openssl \
openssh \
curl \
wget \
git \
gnupg \
make \
xz \
gcc \
musl-dev \
libstdc++
# Install Golang
COPY --from=golang:1.19-alpine /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"
# Install Node.js
COPY --from=node:16-alpine /usr/local/ /usr/local/
ENV NODE_PATH="/usr/local/lib/node_modules"
ENV PATH="/usr/local/bin:${PATH}"
# Set the working directory
WORKDIR /opengist
# Copy all source files
COPY . .
# Build the application
RUN make
# Expose the port for the webserver
EXPOSE 6157
# Mount the .opengist volume
VOLUME /root/.opengist
# Run the webserver
CMD ["./opengist"]

View file

@ -1,4 +1,4 @@
.PHONY: all install_deps build_frontend build_backend clean
.PHONY: all install_deps build_frontend build_backend build_docker clean clean_docker
# Specify the name of your Go binary output
BINARY_NAME := opengist
@ -19,8 +19,15 @@ build_backend:
@echo "Building Opengist binary..."
go build -o $(BINARY_NAME) opengist.go
build_docker:
@echo "Building Docker image..."
docker build -t opengist .
clean:
@echo "Cleaning up build artifacts..."
@rm -f $(BINARY_NAME) public/manifest.json
@rm -rf node_modules public/assets
clean_docker:
@echo "Cleaning up Docker image..."
@docker rmi opengist

2
go.mod
View file

@ -1,6 +1,6 @@
module opengist
go 1.18
go 1.19
require (
github.com/go-playground/validator/v10 v10.11.0