done w docker shit

This commit is contained in:
yuzu 2025-05-05 19:04:30 -05:00
parent bca22601e1
commit f9e148f9ee
6 changed files with 66 additions and 2 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
.zig-cache/
zig-out/

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
zig-out/ zig-out/
zig-cache/ zig-cache/
data/
*.core *.core
.jetzig .jetzig
.zig-cache/ .zig-cache/

36
Dockerfile Normal file
View File

@ -0,0 +1,36 @@
FROM alpine:latest AS build
RUN apk add jq curl tar xz git vim
RUN curl --output /zig.tar.xz "$(curl -s 'https://ziglang.org/download/index.json' | jq -r '.master."x86_64-linux".tarball')"
RUN mkdir /zig
WORKDIR /zig
RUN tar -xf /zig.tar.xz
RUN mkdir /app
COPY . /app/
WORKDIR /app/
RUN /zig/zig-*/zig build -Denvironment=production install
run mkdir /jetzig
WORKDIR /jetzig
RUN git clone https://github.com/jetzig-framework/jetzig .
WORKDIR ./cli
RUN /zig/zig-*/zig build install
FROM alpine:latest
# copy zig over
RUN mkdir /.zig
COPY --from=build /zig/zig-*/ /.zig
ENV PATH="/.zig:$PATH"
# copy jetzig over
COPY --from=build /jetzig/cli/zig-out/bin/jetzig /usr/local/bin/jetzig
RUN mkdir -p /app/public
COPY --from=build /app /app
COPY --from=build /app/zig-out/bin/yuzucchiidotxyz /app/server
WORKDIR /app/
EXPOSE 8080
ENTRYPOINT ["./server"]
CMD ["/app/server", "--bind", "0.0.0.0", "--port", "8080"]

View File

@ -6,7 +6,7 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = "yuzucchii.xyz", .name = "yuzucchiidotxyz",
.root_source_file = b.path("src/main.zig"), .root_source_file = b.path("src/main.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,

View File

@ -1,8 +1,31 @@
services: services:
server:
env_file: ".env"
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
restart: unless-stopped
depends_on:
- postgres
networks:
- postgres-network
postgres: postgres:
image: postgres:16 image: postgres:16
env_file: ".env"
environment: environment:
POSTGRES_USER: ${JETQUERY_USERNAME} POSTGRES_USER: ${JETQUERY_USERNAME}
POSTGRES_PASSWORD: ${JETQUERY_PASSWORD} POSTGRES_PASSWORD: ${JETQUERY_PASSWORD}
ports: ports:
- 5432:5432 - "5431:5432"
volumes:
- ./data/:/var/lib/postgresql/data/
networks:
- postgres-network
networks:
postgres-network:
driver: bridge

View File

@ -7,5 +7,6 @@ pub const database = .{
}, },
.production = .{ .production = .{
.adapter = .postgresql, .adapter = .postgresql,
.hostname = "postgres"
}, },
}; };