Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add files for docker deploy #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dodaj još .env.example, yarn-error.log, .vscode i compose.* da maknemo još te nepotrebne stvari

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.env
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
postgres-data
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ yarn-error.log*
# dev stuff
/dev/*
!/dev/.gitkeep

#postgres
postgres-data
sql/ctf_popunjeno.sql
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM node:20-alpine AS deps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls koristi zadnji LTS (node 22). Node 20 ide u maintainance mode za koji tjedan.

Preporučam napraviti nešto kao:

FROM node:22-alpine AS base


FROM base AS deps
...

RUN apk add --no-cache libc6-compat openssl
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn --frozen-lockfile

FROM node:20-alpine AS builder
ARG APP_FILE_STORAGE_DIR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ovi argovi su nepotrebni, pls ih makni

ARG APP_PUBLIC_URL
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preporučam da dodaš

ENV NEXT_TELEMETRY_DISABLED 1
ENV SKIP_ENV_VALIDATION 1

da ne šaljemo telemetriju pri CI buildovima baš

RUN SKIP_ENV_VALIDATION=1 yarn build

FROM gcr.io/distroless/nodejs20-debian12 AS runner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zašto koristiš drugačiju verziju nodejs za build i release?
Pls standardiziraj na gore naveden base koji dodaš

WORKDIR /app

ENV NODE_ENV production

COPY --from=builder /app/next.config.mjs ./
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jedino što je potrebno kopirati su public, .next/standalone i .next/static, pls makni ostale

COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

EXPOSE 3000
ENV PORT 3000

CMD ["server.js"]
21 changes: 21 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
db:
image: postgres:13-alpine
restart: always
env_file:
- .env
volumes:
- ./postgres-data/data:/var/lib/postgresql/data/
- ./sql:/docker-entrypoint-initdb.d/
app:
build:
context: .
args:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makni ove args, nepotrebni su

APP_FILE_STORAGE_DIR: ${APP_FILE_STORAGE_DIR}
APP_PUBLIC_URL: ${APP_PUBLIC_URL}
working_dir: /app
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Također nepotrebno, može potrgati stvar ako se promijeni dockerfile

ports:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ports ne treaba biti u compose file-u. To se dodaje u override (jer npr. za naše potrebe ne želimo exposati niti jedan port)

- "3000:3000"
image: comp_ctf_2023
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ovo isto nije dobro da je tu, pls makni

env_file:
- .env
297 changes: 297 additions & 0 deletions sql/ctf.sql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Što je ova datoteka i zašto je tu?

Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
--
-- PostgreSQL database dump
--

-- Dumped from database version 13.17
-- Dumped by pg_dump version 13.17

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: TaskDifficulty; Type: TYPE; Schema: public; Owner: comp_ctf_2023
--

CREATE TYPE public."TaskDifficulty" AS ENUM (
'easy',
'medium',
'hard'
);


ALTER TYPE public."TaskDifficulty" OWNER TO comp_ctf_2023;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: account; Type: TABLE; Schema: public; Owner: comp_ctf_2023
--

CREATE TABLE public.account (
"userId" text NOT NULL,
type text NOT NULL,
provider text NOT NULL,
"providerAccountId" text NOT NULL,
refresh_token text,
refresh_token_expires_in integer,
access_token text,
expires_at integer,
token_type text,
scope text,
id_token text,
session_state text
);


ALTER TABLE public.account OWNER TO comp_ctf_2023;

--
-- Name: session; Type: TABLE; Schema: public; Owner: comp_ctf_2023
--

CREATE TABLE public.session (
"sessionToken" text NOT NULL,
"userId" text NOT NULL,
expires timestamp without time zone NOT NULL,
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.session OWNER TO comp_ctf_2023;

--
-- Name: task; Type: TABLE; Schema: public; Owner: comp_ctf_2023
--

CREATE TABLE public.task (
id integer NOT NULL,
slug text NOT NULL,
"flagBase" text NOT NULL,
"flagUserSpecific" boolean DEFAULT true NOT NULL,
title text NOT NULL,
description text NOT NULL,
text text NOT NULL,
handler text,
difficulty public."TaskDifficulty" NOT NULL,
"position" integer NOT NULL,
hidden boolean DEFAULT false NOT NULL
);


ALTER TABLE public.task OWNER TO comp_ctf_2023;

--
-- Name: taskSolves; Type: TABLE; Schema: public; Owner: comp_ctf_2023
--

CREATE TABLE public."taskSolves" (
"taskId" integer NOT NULL,
"userId" text NOT NULL,
"startedAt" timestamp without time zone DEFAULT now() NOT NULL,
"finishedAt" timestamp without time zone,
flag text NOT NULL,
metadata json DEFAULT '{}'::json NOT NULL
);


ALTER TABLE public."taskSolves" OWNER TO comp_ctf_2023;

--
-- Name: task_id_seq; Type: SEQUENCE; Schema: public; Owner: comp_ctf_2023
--

CREATE SEQUENCE public.task_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


ALTER TABLE public.task_id_seq OWNER TO comp_ctf_2023;

--
-- Name: task_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: comp_ctf_2023
--

ALTER SEQUENCE public.task_id_seq OWNED BY public.task.id;


--
-- Name: user; Type: TABLE; Schema: public; Owner: comp_ctf_2023
--

CREATE TABLE public."user" (
id text NOT NULL,
name text,
email text NOT NULL,
"emailVerified" timestamp without time zone,
image text,
role character varying(50)
);


ALTER TABLE public."user" OWNER TO comp_ctf_2023;

--
-- Name: verificationToken; Type: TABLE; Schema: public; Owner: comp_ctf_2023
--

CREATE TABLE public."verificationToken" (
identifier text NOT NULL,
token text NOT NULL,
expires timestamp without time zone NOT NULL
);


ALTER TABLE public."verificationToken" OWNER TO comp_ctf_2023;

--
-- Name: task id; Type: DEFAULT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public.task ALTER COLUMN id SET DEFAULT nextval('public.task_id_seq'::regclass);

--
-- Data for Name: task; Type: TABLE DATA; Schema: public; Owner: comp_ctf_2023
--

COPY public.task (id, slug, "flagBase", "flagUserSpecific", title, description, text, handler, difficulty, "position", hidden) FROM stdin;
1 kopija-pasta owo_je_zastawica_ t kopija/pašta Primjer zadatak za Comp CTF. Ovo je primjer zadatak za Comp CTF.\nSvaki zadatak ima "zastavicu" koju moraš naći i upisati u odgovarajuće polje. Zastavice nisu osjetljiva na velika i mala slova te sadrze iskljucivo slova.\nAko rješenje zadatka nije zastavica, to će biti naznačeno u tekstu zadatka.\n\nRješenje za ovaj zadatak je %%FLAG%%.\n\nZadatci neće uvijek biti ovako lagani, tako da nije sramota rješavati uz kolegu ili pitati na COMP pultu za savjet.\nJedino nemojte dijeliti rješenja s ostalima ili ih postati na razne kanale da ne umanjite zabavu drugima. easy 1 f
2 kset-kafica prijatna_kafica f KSET kafica Skeniraj QR kod u KSET-u (i možda ostani na kavici s kolegama) Skeniraj QR kod u KSET-u (i možda ostani na kavici s kolegama) easy 2 t
3 jpeg-zip zip_zap_kompres_ t jpeg.zip Kolega je rekao da će mi poslati zip, ali sam dobio samo jpeg... Kolega je rekao da će mi poslati zip, ali sam dobio samo neki potrgani jpeg. Mozes li mi pomoći? jpeg-with-zip medium 3 f
4 igra-skrivaca inspect_element_vs_view_source_ t Igra skrivača Unutar sadržaja ove stranice ugrađena je zastavica - pronađi je. Unutar sadržaja ove stranice ugrađena je zastavica - pronađi je. add-flag-to-page-in-link-tag-url easy 4 f
5 kolektor-kolacica cookie_clicker_ t Kolektor kolačića Bok ja sam cookie s komadićima čokolade. MOOOOLIM te nemoj me pojesti!!!!! UwU Bok ja sam cookie s komadićima čokolade. MOOOOLIM te nemoj me pojesti!!!!! UwU add-cookie-with-flag easy 5 f
6 mozdano-opcenje up_up_down_down_left_right_left_right_b_a_ t Moždano općenje ... %%BRAINFUCK%% add-%%BRAINFUCK%%-variable-to-text easy 6 f
7 3310 ne_zaboravite_uzet_mlijeko_kad_budete_se_vracali_doma_ t 3310 Mama je napokon kupila smartphone jučer. Pazi kaj mi je poslala na wapp. Note: razmak predstavlja pauzu.\nLegenda:\n? je {\n! je }\n- je _\n\n\nMama je napokon kupila smartphone jucer. Pazi kaj mi je poslala na wapp.\n%%TEXT_CODE%% add-%%TEXT_CODE%%-variable-to-text medium 7 f
8 htt-postar get_with_the_post_ t HTTPoštar Bok! Ja sam poštar. Pošalji mi ime tvoje omiljene životinje! Bok! Ja sam poštar, moja adresa je %%ENDPOINT_URL%%. Pošalji mi ime tvoje omiljene životinje.\n\nBitno! U zaglavlju me naslovi s To: KSET i From: %%SESSION_ID%% http-postar medium 8 f
9 4-x-16-x-4 hexed_ t 4x16x4 24 znaka, 2 boje, 4 reda, tekst čudaka 24 znaka, 2 boje, 4 reda, tekst čudaka\n\n%%MESSAGE%% poruka-u-hex-bojama medium 9 f
10 bazirano-na-istintoj-prici ne_mora_biti_samo_baza_sestnaest_ili_sezdeset_cetiri_ t Bazirano na istintoj priči ... Baze brojeva mogu biti raznolike. Jedan od načina za enkodiranje binarnih podataka je npr. base64...\n\n...ali to je pre mainstream za nas! Mi koristimo samo bazu 36! To je baza koja sadrži brojeve pa sve znakove engleske abecede.\n\nPitam se što se krije iza ovih slova...\n\n%%ENCODED_FLAG%% ascii-base-36 medium 10 f
\.


--
-- Name: task_id_seq; Type: SEQUENCE SET; Schema: public; Owner: comp_ctf_2023
--

SELECT pg_catalog.setval('public.task_id_seq', 10, true);


--
-- Name: account account_provider_provideraccountid; Type: CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public.account
ADD CONSTRAINT account_provider_provideraccountid PRIMARY KEY (provider, "providerAccountId");


--
-- Name: session session_pkey; Type: CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public.session
ADD CONSTRAINT session_pkey PRIMARY KEY ("sessionToken");


--
-- Name: task task_pkey; Type: CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public.task
ADD CONSTRAINT task_pkey PRIMARY KEY (id);


--
-- Name: task task_position_unique; Type: CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public.task
ADD CONSTRAINT task_position_unique UNIQUE ("position");


--
-- Name: task task_slug_unique; Type: CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public.task
ADD CONSTRAINT task_slug_unique UNIQUE (slug);


--
-- Name: taskSolves tasksolves_taskid_userid; Type: CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public."taskSolves"
ADD CONSTRAINT tasksolves_taskid_userid PRIMARY KEY ("taskId", "userId");


--
-- Name: user user_pkey; Type: CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public."user"
ADD CONSTRAINT user_pkey PRIMARY KEY (id);


--
-- Name: verificationToken verificationtoken_identifier_token; Type: CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public."verificationToken"
ADD CONSTRAINT verificationtoken_identifier_token PRIMARY KEY (identifier, token);


--
-- Name: position_idx; Type: INDEX; Schema: public; Owner: comp_ctf_2023
--

CREATE INDEX position_idx ON public.task USING btree ("position");


--
-- Name: account account_userId_user_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public.account
ADD CONSTRAINT "account_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES public."user"(id) ON DELETE CASCADE;


--
-- Name: session session_userId_user_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public.session
ADD CONSTRAINT "session_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES public."user"(id) ON DELETE CASCADE;


--
-- Name: taskSolves taskSolves_taskId_task_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public."taskSolves"
ADD CONSTRAINT "taskSolves_taskId_task_id_fk" FOREIGN KEY ("taskId") REFERENCES public.task(id) ON DELETE CASCADE;


--
-- Name: taskSolves taskSolves_userId_user_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: comp_ctf_2023
--

ALTER TABLE ONLY public."taskSolves"
ADD CONSTRAINT "taskSolves_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES public."user"(id) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--